开发者

htaccess remove www from URL respect RewriteBase

开发者 https://www.devze.com 2023-02-12 23:10 出处:网络
In base directory it works fine, but if you go in subdirectory: example www.domain.com/dir/ used RewriteBase is lost.

In base directory it works fine, but if you go in subdirectory: example www.domain.com/dir/ used RewriteBase is lost. In htaccess I have something like this....

Options +FollowSymLinks
RewriteEngine On
RewriteBase /dir/
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule (.*) http://%1/$1 [R=301,L]

RewriteRule ^home/?$ index.php [L] 

So if we put www.domain.com/dir/home it redirect us to http://domain.com/home and /dir/ is missing ... What I is wrong ... T开发者_运维百科hanks for ideas.


Just put dir in Rule

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/dir/$1 [L,R=301]
0

精彩评论

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

关注公众号