2012-10-25 70 views
2

我在我的htaccess文件中寫入規則,但是兩條規則相互衝突。 我htaccess文件是:在htaccess文件中重寫規則衝突?

# BEGIN REMOVE SLUG CUSTOM POST TYPE RULES 
RewriteRule ^service-status/(.+)/$ /$1 [R=301,L] 
RewriteRule ^country/(.+)/$ /$1 [R=301,L] 
RewriteRule ^company/(.+)/$ /$1 [R=301,L] 
# END REMOVE SLUG CUSTOM POST TYPE RULES 


RewriteRule ^([a-zA-Z0-9_-]+)/numero/$ ?country=$1 
RewriteRule ^introduction/([a-zA-Z0-9_-]+) ?company=$1 
RewriteRule ^pays/(.+)?$ /pays?company=$1 
RewriteRule ^([^/]*)/([^/]*)/$ /index.php?country=$1&company=$2 

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

# END WordPress 
all rule working fine but 
RewriteRule ^([^/]*)/([^/]*)/$ /index.php?country=$1&company=$2 
RewriteRule ^([a-zA-Z0-9_-]+)/numero/$ ?country=$1 
conflict each other both are working fine Individually 

我想網址喜歡 1. http://abc.com/country-name/companyname/

(RewriteRule ^([^/]*)/([^/]*)/$ /index.php?country=$1&company=$2) 

2.http://abc.com/country-name/numero/(NUMERO是固定關鍵詞)

RewriteRule ^([a-zA-Z0-9_-]+)/numero/$ ?country=$1 

我會感謝您的幫助。 感謝 Ballu

回答

1

試試這個:

# BEGIN REMOVE SLUG CUSTOM POST TYPE RULES 
RewriteRule ^service-status/(.+)/$ /$1 [R=301,L] 
RewriteRule ^country/(.+)/$ /$1 [R=301,L] 
RewriteRule ^company/(.+)/$ /$1 [R=301,L] 
# END REMOVE SLUG CUSTOM POST TYPE RULES 


RewriteRule ^([a-zA-Z0-9_-]+)/numero/$ ?country=$1 
RewriteRule ^introduction/([a-zA-Z0-9_-]+) ?company=$1 
RewriteRule ^pays/(.+)?$ /pays?company=$1 
RewriteRule ^([^/]*)/([^/]*)/$ /index.php?country=$1&company=$2 

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

# END WordPress 
RewriteRule ^([a-zA-Z0-9_-]+)/numero/$ ?country=$1 [L] 
RewriteRule ^([^/]*)/([^/]*)/$ /index.php?country=$1&company=$2 [L] 
+0

謝謝你的工作對我來說:) –