我有這樣的代碼重寫的路徑,然後重定向到子域的文件夾的路徑:的.htaccess重寫路徑:新查詢字符串刪除第一個斜線
RewriteEngine On
RewriteBase/
RewriteRule ^category/?$ category.php
RewriteRule ^category/[a-z0-9\-]+\_([A-Z0-9\_]+)/?$ articles.php?id=$1§ion=category
RewriteCond %{HTTP_HOST} ^test.(.*)example.com/?$ [NC]
RewriteCond %{REQUEST_URI} !^/\!test/ [NC]
RewriteRule (.*) /!test/$1 [L,NC]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [NE,L,R=301]
最大的問題是,在瀏覽器中鍵入此地址字段,然後按Enter:
http://test.example.com/category/article-about-something_35436
結束了,因爲它本身更改爲:
http://test.example.comcategory/article-about-something_35436
而瀏覽器當然會告訴你「找不到服務器」。
故障排除
我已經想通了,這工作得很好:
http://test.example.com/category
而且從第二重寫規則去除查詢字符串?id=$1§ion=category
工作。當然,你不會在文章結尾,但在articles.php
。
那麼,有誰知道這個問題?
打開Firebug,並參觀'HTTP:// test.example.com /分類/條,約-something_35436'在瀏覽器。現在看看你在'Net'選項卡中得到了什麼重定向。 – anubhava 2014-11-06 20:10:02
沒有什麼,只是空的。但在Chrome的開發人員工具的網絡部分中發生了一些事情。但是我看不到任何能告訴我該怎麼做的事情。我看到一個「301永久移動」。 – 2014-11-06 20:21:11
當你得到301的時候,它被重定向到了什麼地方?此外,你的代碼沒有任何301 – anubhava 2014-11-06 20:25:08