开发者

Incorrect redirection after omitting a trailing slash (.htaccess)

I have the following .htaccess file and I would like to know how can I edit it in order to add the trailing slash and keep the same url. Right now, if I access a link without a trailing slash, it adds the slash but it loses the 'www.' in front of 'mywebsite.com'. Any ideas?

Options +FollowSymLinks

RewriteEngine On

RewriteBase / 

RewriteCond %{REQUEST_FILENAME} !-f 

RewriteCond %{REQUEST_URI} !(.*).html

RewriteCond %{REQUEST_URI} !(.*)/$ 

RewriteRule ^(.*)$ http://mywebsite.com/$1/ [L,R=301]

RewriteRule ^artists/([^/-]+)-p([^/]+)/$ /artists.php?l=$1&p=$2 [QSA,L] 

RewriteRule ^artists/([^/]+)/$ /artists.php?l=$1 [QSA,L] 

RewriteRule ^lyrics/(.*)/(.*)/(.*).html /artists-lyrics.php?a=$1&b=$2&c=$3 

RewriteRule ^lyrics/(.*)/(.*).html /artists-lyrics.php?a=$1&c=$2 [QSA,L] 

RewriteRule ^lyrics/([^/]+)/([^/]+)/$ /artists-albums.php?a=$1&b=$2 [QSA,L] 

RewriteRule ^lyrics/([^/]+)/$ /artists-details.php?a=$1 [QSA,L] 

RewriteRule ^latest/p-([^/-]+)-([^/]+)/$ /latest.php?p=$1&q=$2 [QSA,L] 

RewriteRule ^save-([^/-]+)-([^/-]+)/$ /save.php?t=$1&s=$2 [QSA,L] 

RewriteRule ^latest/$ /latest.php [QSA,L] 

RewriteRule ^top100/$ /top100.php [QSA,L] 

RewriteRule ^p-([^/-]+)-([^/]+)/$ /in开发者_StackOverflowdex.php?p=$1&q=$2 [QSA,L] 

RewriteRule ^submit/$ /submit.php [QSA,L] 

RewriteRule ^users/$ /users.php [QSA,L]  

RewriteCond %{THE_REQUEST} ^.*/index.php 

RewriteRule ^(.*)index.php$ http://www.mywebsite.com/$1 [R=301,L]


This rule is redirecting all requests without a trailing slash to your domain without www:

RewriteRule ^(.*)$ http://mywebsite.com/$1/ [L,R=301]

So if you want to add www, add it right there.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜