Htaccess规则给出301错误

时间:2014-06-18 07:59:45

标签: .htaccess http-status-code-301

我正在尝试更改网址,在我的htaccess中我添加了这一行:

RewriteRule ^/about/$ /site/about_us/

添加此内容后,如果我点击了我的网址http://mydomain.com/about/,则会让我永久移动301并重定向到http://mydomain.com/site/about_us/

我的htaccess文件:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^about/?$ /site/about_us/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

enter image description here

接头:

Response Heades:
HTTP/1.1 301 Moved Permanently
Date: Wed, 18 Jun 2014 09:42:45 GMT
Server: Apache/2.4.4 (Win64) PHP/5.4.12
X-Powered-By: PHP/5.4.12
X-Pingback: http://soller.local/xmlrpc.php
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
Pragma: no-cache
Location: http://soller.local/site/about_us/
Content-Length: 0
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8


Request Heades:
GET /about/ HTTP/1.1
Host: soller.local
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Cookie: wp-settings-time-1=1393072512; wp-settings-1=libraryContent%3Dupload%26editor%3Dtinymce%26hidetb%3D1; wp-settings-time-47=1390228546; wp-settings-time-877=1392096718; wp-settings-time-2579=1393680813; wp-settings-time-2578=1393427211; wp-settings-time-106=1394689670; wp-settings-time-4965=1396012806; PHPSESSID=28tioc16rbc3314br3smf9djv7; wordpress_logged_in_3bbc4cdbbb4e6dcd108616247c041571=nirajmchauhan%40gmail.com%7C1403246168%7C08fbbba723e8d02b102a50fb5d0dee38; last_navigator_url=http%3A%2F%2Fsoller.local%2Fsite%2Fprofile%2Fmy-assessments%2F; url_route_slug=%2Fniraj; current_navigator_url=http%3A%2F%2Fsoller.local%2Fniraj
Connection: keep-alive

1 个答案:

答案 0 :(得分:0)

您应该删除[PT]重写标志。 您可以在此处了解有关重写标志的更多信息:http://httpd.apache.org/docs/current/rewrite/flags.html#flag_pt

<强> ADDITION

此外,您可能需要在wordpress规则之前移动您的rewriterule。你的代码看起来像这样

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^about/?$ /site/about_us/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress