删除URL .php扩展名会导致404错误
I am rewriting my url to get rid of the .php
extension (and hopefully the get variables too as all the help I have gotten is great, but still wont work.
Here is my code:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php[\s?] [NC]
RewriteRule ^ %1 [R=301,L]
# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+?)/?$ $1.php [NC,L]
Now when I use this code, it takes the .php out, but then the error says:
Not Found
The requested URL /index.php was not found on this server.
Meanwhile, if I take that code out, it works fine, but has the .php
extension
douliao7354
2014/02/23 06:23- apache
- php
- html
- url
- 点赞
- 收藏
- 回答
满意答案
2个回复
