我正在使用htaccess尝试重写url。我已经尝试了大约10个版本的代码和示例,但没有任何更改。我知道mod_rewrite是有效的,因为它将www添加到url中,但虚荣的url不起作用。
RewriteRule ^franchise/([0-9]+)/?$ franchise-information.php?franchiseid=$1 [NC,L] # Handle product requests
这是.htaccess文件:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^www'..+$ [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteRule ^franchise/([0-9]*?)/$ franchise-information.php?franchiseid=$1 [NC,L]
</IfModule>
这是网址:
http://www.playballkids.com/franchise-information.php?franchiseid=162
您可以在DOCUMENT_ROOT/.htaccess
文件中使用以下代码:
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /franchise-information'.php'?franchiseid=([^'s&]+) [NC]
RewriteRule ^ franchise/%1? [R=302,L,NE]
RewriteRule ^franchise/('d+)/?$ franchise-information.php?franchiseid=$1 [NC,L,QSA]