开发者

Htaccess ModRewrite for CodeIgniter with a parked/redirected domain

I have this situation:

  • hosting is located at maindomain.com
  • othersite.com is parked to maindomain.com
  • htaccess is used to redirect all requests for othersite.com to a subfolder: /site-othersite/
  • I want to use CodeIgniter on othersite.com but there are some directories and files in othersite.com that I don't want to have the CodeIgniter redirection.
  • home.php is my CodeIgniter main page.

I have tried to combine the usual ModRewrite that I use for my parked domains with what I found in the CodeIgniter wiki but am having trouble.

Example: I do not want othersite.com/demo/ or othersite.com/robots.txt to be handled by CodeIgniter. I have this:

# Redirect various urls to subfolders of the format: /site-thename/

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?othe开发者_StackOverflowrsite\.com
RewriteCond %{REQUEST_URI} !^/site-othersite/
RewriteCond %{REQUEST_URI} !^/demo/
RewriteCond %{REQUEST_URI} !^robots\.txt

Rewriterule ^(.*)$ /site-othersite/home.php?/$1 [L]

Everything works fine for the CodeIgniter install. Except trying to get demo/ and robots.txt to be 'ouside' of CodeIgniter is not working.

And ModRewrite masters out there with suggestions? Thank you!


Figured it out. It needs to be handled in two rules:

# Redirect various urls to subfolders of the format: /site-thename/

RewriteEngine On

# Handle pages and directories that should not go through CodeIgniter.
RewriteCond %{HTTP_HOST} ^(www\.)?othersite\.com
RewriteCond %{REQUEST_URI} !^/site-othersite/
RewriteCond %{REQUEST_URI} ^/demo/ [OR]
RewriteCond %{REQUEST_URI} ^/robots.txt

Rewriterule ^(.*)$ /site-othersite/$1 [L]


# Handle CodeIgniter URLs.
RewriteCond %{HTTP_HOST} ^(www\.)?othersite\.com
RewriteCond %{REQUEST_URI} !^/site-othersite/

Rewriterule ^(.*)$ /site-othersite/home.php?/$1 [L]
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜