这些 htaccess 规则让我发疯,我尝试了大量的示例和生成器并在这里了解...
我的 htaccess 如下所示
Options +FollowSymLinks
DirectoryIndex index.php
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.domain.com [NC]
RewriteRule ^(.*)$ http://domain.co.uk/$1 [L,R=301]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.domain.com/ [R=301,L]
RewriteRule ^location/([^/]*)\.html$ /location.php?location=$1 [R=301,L]
RewriteRule ^([^/]*)\.html$ /search.php?searching=yes&s=$1 [R=301,L]
我试图得到
http://www.domain.com
to http://domain.com (works)
http://domain.com/index.php
to http://domain.com (works)
将所有 php 扩展重写为 html 即
http://domain.com/location.php
to http://domain.con/location.html (doesnt work)
http://domain.com/about.php
to http://domain.con/about.html (doesnt work)
http://domain.com/support.php
to http://domain.com/support.html (doesnt work)
重写以下变量
http://domain.com/location.php?location=bedfordshire
to http://domain.com/location/bedfordshire.html (doesnt work)
http://domain.com/search.php?searching=yes&s=langster&pmin=&daf=&search=&pmax=&dab=
to http://domain.com/langster.html (doesnt work)
一些页面,如 index.php、location.php 和 search.php 有页面和其他变量,但我真的不想进入那个蠕虫罐头。