views:

14

answers:

1

Hello,

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 ideeas?

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-([^/-]+)-([^/]+)/$ /index.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]
+1  A: 

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.

Dan Grossman
Ok, and if I want to redirect all the requests without www to the url with www?
Psyche
This is a separate question, and does not belong in the comments of an existing question. Plus, there are dozens of articles telling you the two-line rule to accomplish that a quick search away.
Dan Grossman