2013-09-23 32 views
1

我有以下代碼...的.htaccess重新定向發行/重新寫入規則衝突

RewriteEngine On 

RewriteRule ^(css|js|admin|scripts|É)(/|$) - [L] 

RewriteCond %{DOCUMENT_ROOT}$0 -d 

RewriteRule ^[^/]+ - [L] 

# Redirect .htm to index.php 
RewriteRule ^(.*)\.htm /index.php?name=$1&id=$2 [L] 

RewriteRule ^(.*)\ /index.php?name=$1&id=$2 [L] 

工作正常。

不過,我需要補充301重新定向,所以我加了如下因素:

# Below are the re-directs needed. 
Redirect 301 /oldlink.htm /newlink.htm 

當我不過oldlink.htm我得到newlink.htm名= oldlink & ID =

這不是我想要的,我需要它轉到newlink.htm

任何人都可以幫忙嗎?

+0

使用'RewriteLog'調試規則。 – DanFromGermany

回答

1
  1. 避免混合的mod_proxy和mod_rewrite的
  2. 您將需要一個RewriteCond防止規則的適用後301
  3. 你的規則是不正確或者。

這種替換代碼:

RewriteEngine On 

RewriteRule ^oldlink\.htm$ /newlink.htm [L,R=301,NC] 

# Redirect .htm to index.php 
RewriteRule ^(.*)\.html?$ /index.php?name=$1 [L,QSA,NC] 

## If the request is for a valid directory 
RewriteCond %{REQUEST_FILENAME} -d [OR] 
## If the request is for a valid file 
RewriteCond %{REQUEST_FILENAME} -f [OR] 
## If the request is for a valid link 
RewriteCond %{REQUEST_FILENAME} -l 
## don't do anything 
RewriteRule^- [L] 

RewriteRule ^(css|js|admin|scripts|É)/?$ - [L] 

## DON'T KNOW WHAT THIS RULE IS DOING 
#RewriteRule ^(.*)\ /index.php?name=$1 [L,QSA,NC] 
+0

現貨上,非常感謝你! –

+0

不客氣,很高興它爲你解決。 – anubhava