我有舊的網址,並希望通過的.htaccess刪除/index.php/:ModRewrite刪除/index.php/
所以舊的URL是:
www.mysite.com/index.php/onesite.html
重寫在.htaccess到
www.mysite.com/onesite.html
我怎麼能這樣做?
THX對您有所幫助
我有舊的網址,並希望通過的.htaccess刪除/index.php/:ModRewrite刪除/index.php/
所以舊的URL是:
www.mysite.com/index.php/onesite.html
重寫在.htaccess到
www.mysite.com/onesite.html
我怎麼能這樣做?
THX對您有所幫助
您可以使用這條規則在您DOCUMENT_ROOT/.htaccess
文件:
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^index\.php(/.*)?$ $1 [L,R=301,NC,NE]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+?)/?$ /index.php/$1 [L]
添加以下代碼到你的htaccess將允許該
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^index.php/(.*)$ www.mysite.com/$1 [R=302,L]
更改302
到301
當您確定重定向正在工作時
試試這個:
RewriteRule ^index.php/(.*?)$ http://%{HTTP_HOST}/$1 [R=301,L]
添加一些解釋會很有用。 –
就在你的.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
添加此如果你的網站是在子目錄下,那麼
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /shop/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /shop/index.php [L]
</IfModule>
謝謝你,但它不工作 – cuSoon2013
什麼這個.htaccess的位置和你嘗試過什麼URL? – anubhava