开发者

Very strange .htaccess rewrite problem

I'm having a weird problem with my .htaccess

I have the following rewrite rules

#REMOVE TRAILING SLASH
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRu开发者_Go百科le ^(.+)/$ $1 [R=301,L]

#REWRITES
RewriteRule ^clients(/)?$ /views/pages/clients.php [L]
RewriteRule ^about(/)?$ /views/pages/about.php [L]
RewriteRule ^contact(/)?$ /views/pages/contact.php [L]
RewriteRule ^mobile(/)?$ /views/pages/tags.php?tag=mobile [L]
RewriteRule ^tablet(/)?$ /views/pages/tags.php?tag=tablet [L]

These rules do work BUT two of them act strangely.

RewriteRule ^clients(/)?$ /views/pages/clients.php [L]
RewriteRule ^mobile(/)?$ /views/pages/tags.php?tag=mobile [L]

The 'clients' rewrite rule always gets a trailing slash.

The 'mobile' rewrite rule rewrites to http://www.mydomain.com/mobile/?tag=mobile

I need to fix this problem because these rules result into unnecessary redirects which affect my SEO performance

I find this very strange because they are similiar to the other ones and they do just fine.

Another bizar fact: on my localhost the rewrites act just fine, it's on my production server they act strange

Also I just found out that the following rewrite rule acts accordingly:

RewriteRule ^client(/)?$ /views/pages/clients.php [L]

This one doesn't add a trailing slash, so it must be something with the word 'clients' in the left side of the rule.

AND

This rule acts fine also

RewriteRule ^mobiles(/)?$ /views/pages/mobile.php [L]

So, when I use 'clients' and 'mobile' in the left side of the rule, it acts strange. When I use 'client' and 'mobiles' they act just fine.

Can it be that 'clients' and 'mobile' are reserved words or something?


If you have a clients directory on the production server this could cause the issue that you are experiencing with that rewrite. (It's possible that there might be a similar problem with the existence of a mobile directory on the production server, but I cannot be certain without doing some testing myself.)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜