简体   繁体   中英

Apache: RewriteRule suddenly stopped working

The path to my page is like wamp/www/a/b/c. In the last "c" Folder there is a .htaccess:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?p=$1 [L,QSA]

Until today, it worked, it redirected all calls to localhost/a/b/c/path1/path2 to localhost/a/b/c/index.php?p=path1/path2 . But today no more - all calls like localhost/a/b/c/something are redirected to localhost start page. I don't know why. I made a quick workaround changing last line to

RewriteRule ^(.*)$ a/b/c/index.php?p=$1 [L,QSA]

Any idea how to fix this (not to use the path in .htaccess file).

I haven't changed any server configs last time.

It is because your RewriteBase is incorrect. It should reflect the relative path from DocumentRoot . Use this:

RewriteEngine on
RewriteBase /a/b/c/

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?p=$1 [L,QSA]

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM