1
#RewriteEngine On
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_FILENAME}\.php -f
#RewriteRule ^(.*)$ $1.php
RewriteEngine On
RewriteBase/
# Use the following rule if you want to make the page like a directory
RewriteRule ^user/(!(profile.php))$ user/$1/ [R=301,L]
# The following rule does the rewrite.
RewriteRule ^user/(.+)/$ profile.php?id=$1
# The following rewrite the other way round:
RewriteCond %{REQUEST_URI} ^/profile.php
RewriteCond %{THE_REQUEST} ^(GET|POST|HEAD|TRACE)\ /profile.php
RewriteCond %{QUERY_STRING} id=([^&]+)
RewriteRule ^profile.php$ user/%1?
<files .htaccess>
order allow,deny
deny from all
</files>
RewriteCond %{HTTP_HOST} ^www\.mysite\.com$
RewriteRule ^(.*)$ "http\:\/\/mysite\.com\/$1" [R=301,L]
当我访问此网址: http://mysite.com/user/john/ - 这完全完美的作品! 但是,当我存取权限的URL没有斜杠结尾,就像这样:http://mysite.com/user/john浏览器告诉我这个错误:的.htaccess做我的网址结尾没有斜杠“未找到”
我应该怎么做吗?您的帮助将不胜感激,并获得奖励!
谢谢! :-)
所以你在这里做的是强制URL在最后有一个斜杠,对吧? :) – PinoyStackOverflower 2012-08-13 03:30:20
@ElsonSolano是的,它看起来像你原来的规则是试图做到这一点,而你的重写规则'RewriteRule^user /(.+)/$ profile.php?id = $ 1'特别与尾部的斜线匹配,所以没有它,没有任何反应。 – 2012-08-13 03:36:54