2011-11-21 54 views
2

以下重寫規則正常工作修改一個重寫規則

RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} !(.*)/$ 
RewriteRule ^(.*)$ http://domain.com/$1/ [L,R=301] 

,直到我把這個剛剛好低於

RewriteRule ^([a-z0-9]+)/$ /profile/company-profile.php?cname=$1 [NC,L] 

現在每domain.com/something-here轉到公司-profile.php

我該如何解決這個問題?

首先,domain.com/login帶您到登錄文件夾的index.php
當我鍵入第二重寫規則,如果我寫domain.com/login它再次顯示(背景)的公司profile.php的cname =登錄

+1

有什麼預期的效果?給出一個例子,說明什麼時候應該發生,什麼時候發生,爲什麼不發生。 – mario

+0

@mario沒有.. – EnexoOnoma

+1

你正在重定向類似於:'abc'到/profile/company-profile.php和'abc'到'/ $ 1 /',所以誰先來誰誰就會統治 –

回答

3

我會建議使用此?

RewriteEngine On 
RewriteBase/

# redirect company specific request 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([a-z0-9\-_]+)/?$ profile/company-profile.php?cname=$1 [NC,L] 

# redirect all others 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteCond %{REQUEST_URI} !/?$ 
RewriteRule ^(.*)$ http://domain.com/$1/ [L,R=301] 
+0

我想不要公司部分雖然 – EnexoOnoma

+0

,所以你想'([a-z0-9 \ -_] +)'重定向到配置文件/公司和'(。*)'到其他一切? –

+0

我想如果找到一個文件夾重定向它,否則,如果沒有發現公司profile.php – EnexoOnoma