开发者

Rewrite main domain to folder

I'm running a MediaWiki install, for which I recently switched from an addon domain (cpanel) to a parked domain, because that was cheaper and with .htaccess I could still redirect everything. This works for several domains, including this one, but now another error occurs.

When parking the domain I redirect it to /public_html/, in which I have the following .htaccess rules:

RewriteCond %{HTTP_HOST} ^(.*\.)?thedomain.com$
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) http://www.thedomain.com/$1 [R=301]

RewriteCond %{HTTP_HOST} ^www.thedomain.com$
RewriteRule ^(.*)$ thedomain.com/$1 [L]

thus enforcing a www and then redirecting it to the thedomain.com/ folder on my server

as stated before, this all works just as well as an addon slot, so I want to keep it this way.

In the thedomain.com/ folder I have the following rules:

#main page
RewriteCond %{REQUEST_URI} ^/$
RewriteRule (.*) /wiki/Main_Page [R,L]

The goal of this rule is to redirect everyone that goes to www.thedomain.com directly to the wiki's main page. This always used to work, but since I used the .htaccess as described above (for the parked domain) I just get a list of my files in the thedomain.com/ folder.. Why isn't this rule redirec开发者_如何学运维ting to the correct page?

When I manually type in www.thedomain.com/wiki/Main_Page it works, indicating that the problem shouldn't be in the first .htaccess but in the second.


Apparently changing the rule in the main .htaccess to:

RewriteCond %{HTTP_HOST} ^www.mansonwiki.com$
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ wiki/Main_Page [R,L]

RewriteCond %{HTTP_HOST} ^www.mansonwiki.com$
RewriteRule ^(.*)$ mansonwiki.com/$1 [L]

did the trick. Not very neat, but it works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜