开发者

.htaccess issue

开发者 https://www.devze.com 2022-12-18 18:31 出处:网络
I\'m using the .htaccess file below to force a redirect to a \"language prefix\" if none is found in the url. So if domain.com/news is typed it redirects to domain.com/en/news - this works fine.

I'm using the .htaccess file below to force a redirect to a "language prefix" if none is found in the url. So if domain.com/news is typed it redirects to domain.com/en/news - this works fine.

This rule should not be applied to certain folders like images, swf and myphp. It works fine for the first two, so when I access domain.com/swf I see a list of directory content and "en" is not added.

But, it doesn't work for the "myphp" folder (this is a phpmyadmin installation). Normally it would load myphp/index.php but adding the file name to the rule makes no difference. The page just keeps loading but nothing happens. Does anyone know why?

RewriteEngine On
RewriteBase /

#force redirect to language specific page
RewriteCond $1 !^(en|fr|nl)$

#dont a开发者_开发问答pply the rule to the assets folders
RewriteCond $1 !^images$
RewriteCond $1 !^swf$
RewriteCond $1 !^myphp$

#redirect to default EN page if no language param is present in URI
RewriteRule ^([^/]+)/.* /en/$0 [L,R=301]

#remove index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteRule ^(.*)$ /index.php?$1 [L]


seems to me that you might be running into problems due to trying to match the end of the line ($) after the folder name when there's more in the url. What happens if you leave the dollar sign off of your folder names?

0

精彩评论

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