开发者

cannot redirect subfolders via htaccess mod_rewrite

开发者_JAVA百科i have a htaccess problem

all urls will redirect via access:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?load=content&url=$1

Domain www.domain.de/nicepage will redirect to www.domain.de/index.php?load=content&url=nicepage

Now I would like to redirect 'subfolder':

from www.domain.de/faq/nicefaq to www.domain.de/index.php?load=faqdetail&url=nicefaq

That's what I am try:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?load=content&url=$1
RewriteRule ^faq/(.*)$ index.php?load=faqdetail&url=$1

This does not work. everytime i call the page i will redirect to load=content.

Can You help me pls?

thanks in advance and best regards Maddin


Both RewriteRules match against the same condition. As the first you wrote matches everything, the second is never reached. Just change the order:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^faq/(.*)$ index.php?load=faqdetail&url=$1
RewriteRule ^(.*)$ index.php?load=content&url=$1

Hope this helps...


Try this code in your .htaccess file:

Options +FollowSymlinks -MultiViews
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^faq/(.*)$ index.php?load=faqdetail&url=$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/+faq [NC]
RewriteRule ^(.*)$ index.php?load=content&url=$1 [L,QSA]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜