开发者

mod_rewrite to a directory

开发者 https://www.devze.com 2022-12-16 20:25 出处:网络
Im trying to create a rewrite rule to a different directory, but unfortunatly its not working. My current rewrite sends everything back to the index.php file unless the first word in the query string

Im trying to create a rewrite rule to a different directory, but unfortunatly its not working.

My current rewrite sends everything back to the index.php file unless the first word in the query string is admin. The rewrite rule for 'admin' is to admin.php, but i actually want it to go to /var/www/html/website.com/admin/admin.php (instead of the file in the same directory).

This is current .htaccess file.

RewriteEng开发者_StackOverflowine On
RewriteRule ^(.*\/?).*(css|images|js/)+.*$ - [L]
RewriteRule ^\/?admin\/?(.*)$ admin.php?url=$1 [QSA,L]

RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

If i change the rewrite rule for admin to use a different directory..

RewriteRule ^\/?admin\/?(.*)$ /var/www/html/website.com/admin/admin.php?url=$1 [QSA,L]

It breaks the site. Any ideas?

Thanks.


It's actually quite simple, you're using the system path, while web path is needed.

Try the following line:

RewriteRule ^\/?admin\/?(.*)$ /subfolder/admin.php?url=$1 [QSA,L]


Try these rules:

RewriteRule ^admin($|/(.*)) admin/admin.php?url=$2 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php?url=$0 [QSA,L]
0

精彩评论

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

关注公众号