0

我们正在更改网站的结构,旧的 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 %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f

RewriteRule ^(.*)$ index.php/$1

</IfModule>

真正想做的是检查 pages.php 是否被请求,如果是则忽略规则:

RewriteRule ^(.*)$ index.php/$1

然后在此规则之后执行以下操作:

RewriteRule ^PageId=7(.*)$ /niceurl [R=301] 

任何帮助,将不胜感激。

4

1 回答 1

0

解决方案:

<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>
于 2012-04-19T16:35:25.490 回答