1
我試圖做的index.php/index.html的到/可是重定向時我加在上面這段代碼:重寫301 index.php來/上htaccess的不工作
RewriteRule ^index.(php|html|htm)$/[R=301,L]
RewriteRule ^([a-z0-9-_]+)/index.(php|html|htm)$ /$1/ [R=301,L]
我當前代碼不工作性質:
Options FollowSymLinks
RewriteEngine On
#301
RewriteCond %{HTTP_HOST} ^www.domain.pl(.*) [NC]
RewriteRule ^(.*)$ http://domain.pl/$1 [R=301,L]
#STRONA
#Pojedyncza Oferta - jezyki
RewriteRule ^([a-zA-Z]{2})/(.*)/(.*)/(.*).html$ index.php?lang=$1&page=$2&bookmarkTitle=$3&title=$4 [L]
#Aktualnosci, Oferta i Galeria - jezyki
RewriteRule ^([a-zA-Z]{2})/(.*)/(.*).html$ index.php?lang=$1&page=$2&bookmarkTitle=$3 [L]
#Linki - jezyki
RewriteRule ^([a-zA-Z]{2})/(.*).html$ index.php?lang=$1&page=$2 [L]
#Pojedyncza Oferta
RewriteRule ^(.*)/(.*)/(.*).html$ index.php?page=$1&bookmarkTitle=$2&title=$3 [L]
#Aktualnosci, Oferta i Galeria
RewriteRule ^(.*)/(.*).html$ index.php?page=$1&bookmarkTitle=$2 [L]
#Linki
RewriteRule ^([a-zA-Z]{2})/$ index.php?lang=$1 [L]
RewriteRule ^(.*).html$ index.php?page=$1 [L]
<FilesMatch "\.(htm|html|php)$">
<IfModule mod_headers.c>
BrowserMatch MSIE ie
Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie
</IfModule>
</FilesMatch>
ErrorDocument 404 /404.php
加入上面的代碼後,我得到了: domain.pl/page?kontakt代替domain.pl/kontakt.html
如何做到這一點?
謝謝,它的工作原理,但你能告訴我你爲什麼要使用302,而不是301? – SkuterPL
'302'只用於測試,現在可以更改爲301 – anubhava
Okey,301也可以,謝謝:) – SkuterPL