.htaccess检查specfic查询字符串属性
我们正在更改网站的结构,旧的URL如下所示:.htaccess检查specfic查询字符串属性,.htaccess,query-string,.htaccess,Query String,我们正在更改网站的结构,旧的URL如下所示: http://www.website.co.uk/pages.php?PageId=7 新网址为: http://www.website.co.uk/niceurl 我使用的CMS附带了这个.htaccess,所以它的核心功能不能以不同的方式工作 <IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond
http://www.website.co.uk/pages.php?PageId=7
新网址为:
http://www.website.co.uk/niceurl
我使用的CMS附带了这个.htaccess,所以它的核心功能不能以不同的方式工作
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule ^(.*)$ index.php/$1
</IfModule>
然后,按照此规则执行以下操作:
RewriteRule ^PageId=7(.*)$ /niceurl [R=301]
任何帮助都将不胜感激。解决方案:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteCond %{QUERY_STRING} !(PageId=7)
RewriteRule ^(.*)$ index.php/$1
RewriteCond %{QUERY_STRING} PageId=7
RewriteRule .* /niceurl? [R=302,L]
</IfModule>
选项+FollowSymLinks
重新启动发动机
重写基/
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}/index.html-F
重写cond%{REQUEST_FILENAME}/index.php-F
重写cond%{QUERY_STRING}!(PageId=7)
重写规则^(.*)$index.php/$1
RewriteCond%{QUERY_STRING}PageId=7
重写规则。*/niceurl?[R=302,L]
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteCond %{QUERY_STRING} !(PageId=7)
RewriteRule ^(.*)$ index.php/$1
RewriteCond %{QUERY_STRING} PageId=7
RewriteRule .* /niceurl? [R=302,L]
</IfModule>