Forum Moderators: phranque

Message Too Old, No Replies

htaccess help please.

         

thombeal

9:19 pm on Sep 2, 2010 (gmt 0)

10+ Year Member



i host my band's website www.manamucova.com with virgin media.

the actual address is [manamucova.webspace.virginmedia.com...]

but i have url masking so for example www.manamucova.com/music/ goes to the music section, however, if you miss the last slash (www.manamucova.com/music) you lose the url masking and it goes back to the virginmedia site in the address bar.

is there a way to put rewrite rules in htaccess to redirect or somehow to make it so that any time someone goes to a link without the last slash it goes to the correct page without going to the virginmedia page?

i'd appreciate any help.

all i've been able to modify so far in htaccess is an error 404 page which i've just made the same as the homepage for now.

does anyone know if virginmedia supports any other ocding in htaccess?

thank you in advance and i hope it all makes sense!

thombeal

9:21 pm on Sep 2, 2010 (gmt 0)

10+ Year Member



for some reason it's done the virginmedia address as a link.
the address is www.manamucova.webspace.virginmedia.com/manamusite/

jdMorgan

6:29 pm on Sep 3, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have no idea about whether your host allows the use of any particular modules in .htaccess, but if mod_rewrite is allowed, then something like:

Options +FollowSymLinks -Indexes -MultiViews
RewriteEngine on
#
# Externally redirect to add missing trailing slash if no filetype on requested URL-path
RewriteRule ^(([^/]+/)*[^./]+)$ http://www.manamucova.com/$1/ [R=301,L]

would invoke a redirect to the correct domain with an added slash for all requested URLs not containing a period in the final URL-path-part and not ending in a slash.

Having this rule in place pre-empts the action of mod_dir, which would otherwise add a slash and redirect to the canonical domain defined in the server configuration -- doubtless the domain you don't want displayed.

It might also be a good idea to add a second rule after this one, but only after getting the above code working:

# Externally redirect all non-canonical hostname requests to my canonical hostname
RewriteCond %{HTTP_HOST} !^(www\.manamucova\.com)?$
RewriteRule ^(.*)$ http://www.manamucova.com/$1 [R=301,L]

Jim