I'm trying to setup a website based on CodeIgniter. For developing I want to have the domain dev.XXX.com
I changed my structure so I've got a no_www
and a public_www
folder. Both are in the root of dev.XXX.com
So my idea was to rewrite url's form
dev.XXX.com/index.php/test
to
dev.XXX.com/public_www/index.php/test
So I just want add public_www
to all the requests
In my htaccess file I've got:
RewriteRule ^(.*)$ /public_www/$1 [L]
But I always get 500 - Internal Server Error
Try adding the following to the .htaccess
file in the root directory
(
of your site. public_www
)
RewriteEngine on
RewriteBase /
#if its on dev.xxx.com
RewriteCond %{HTTP_HOST} ^dev\.XXX\.com$ [NC]
#if its not already public_www/ rewrite to public_www/
RewriteRule ^(?!public_www/)(.*)$ /public_www/$1 [L,NC]
The rule you had would lead to an infinite rewrite and subsequent 500 error. The one above should prevent that.
EDIT
could you maybe explain why my version leads into a infinite loop
I am likely incorrect about the infinite loop, but below is what will happen
^(.*)$
pattern will match any input /public_www/$1
^(.*)$
pattern will match rewritten input /public_www/$1
/public_www/public_www/$1
Your RewriteRule pattern ^(.*)$
will match all input and will rewrite to . The .htaccess rules will then be run again
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.