简体   繁体   中英

mod_rewrite enabled but does not work properly

About an hour ago, I Added

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} ^(.*[^/])/?$
RewriteCond %{DOCUMENT_ROOT}%1.php -f
RewriteRule .+ %1.php [QSA,L]

to my .htaccess file. but It doesnt work. when I go to mywebsite.com/info or mywebsite.com/info/ it doesnt work (the page is info.php). the mod_rewrite is enabled - tested it by RewriteRule that redirected me to google from any page in my site.

I have no idea what's the problem.. maybe the code is wrong?

Thanks.

@Ron

Try changing the last two lines to this:

RewriteCond %1.php -f
RewriteRule .+ %1.php [PT]

You'll need the [PT] in order for the PHP file to be processed correctly.

This's what I needed for the rules to work:

RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)/$ $1.php [L]

GoDaddy takes about an hour to parse your newly uploaded .htaccess file. It's strange. But the file should work fine as is if you just wait.

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