重写页面,如:
mysite.com/eng/cat
重定向到:
mysite.com/eng?sentence=cat
我制定了以下重写规则:
RewriteCond %{THE_REQUEST} ^GET\ /eng/([^&\s]+) [NC]
RewriteRule ^eng/ eng\?sentence=%1? [R=301,NC,L]
但是当我要求
mysite.com/eng/cat
它像这样重写
mysite.com/eng?sentence=cat?
我不知道为什么最后会打一个问号,我也试过
RewriteCond %{THE_REQUEST} ^GET\ /eng/([^&\s]+) [NC]
RewriteRule ^eng/ eng\?sentence=%1 [R=301,NC,L]
和
RewriteCond %{THE_REQUEST} ^GET\ /eng/([^&\s]+) [NC]
RewriteRule ^eng/ eng\?sentence=%1\? [R=301,NC,L]
这没有任何区别。有什么帮助吗?
我的 htaccess 文件:
# Use PHP5.3 Single php.ini as default
AddHandler application/x-httpd-php54s .php
RewriteEngine on
RewriteCond %{THE_REQUEST} ^GET\s/+eng/([^/?&\s]+) [NC]
RewriteRule ^ eng?sentence=%1 [R=302,NC,L,NE]
AddType application/x-httpd-php .htm .html
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
Options -Indexes
ErrorDocument 404 /404.php
ErrorDocument 500 /500.php
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>