Welcome to WebmasterWorld Guest from 54.167.177.207

Forum Moderators: Ocean10000 & incrediBILL & phranque

Trailing slash redirect

Doesn't seem to be implemented

   
6:19 am on Dec 20, 2005 (gmt 0)

10+ Year Member



Hi

My host doesn't seem to have this.

When a link is clicked with [mydomain...] I get a 400 bad request error.

This a bad because Yahoo has lots of my default index pages listed this way.

Is there a way I can fix this, to corectly redirect to my index, using .htaccess?

Thanks

2:48 pm on Dec 20, 2005 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



We'll need a lot more detail about your URLs to be of any help.

When you say "http://mydomain/test" do you mean that there is no ".com" or ".co.uk" on that domain?

What *is* your index page's correct URL?

Have you searched this forum for "trailing slash" and looked at the posted examples?

JIm

2:43 am on Dec 21, 2005 (gmt 0)

10+ Year Member



Sorry that was typo it should be

[mydomain.com...]

Every directory I have has an index page which isn't found without the trailing slash.

I searched around and found out about mod_dir, which explains my problem.

I tried putting DirectoryIndex index.html in the .htaccess but it made no difference.

If you have any possible solution please let me know.

Thanks

3:07 am on Dec 21, 2005 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I don't understand why mod_dir isn't taking care of this for you... Is it not loaded on your server?

There's another solution using mod_rewrite, but you shouldn't use it unless you absolutely can't get mod_dir enabled properly. It's not very efficient compared to mod_dir, but this should work:


Options +FollowSymLinks
RewriteEngine on
# If REQUEST_URI does NOT(contain a period or end with a slash)
RewriteCond %{REQUEST_URI} !(\./$)
# and it exists as a directory when translated to a server filepath with a slash appended
RewriteCond %{REQUEST_FILENAME}/ -d
# then redirect requested URI after adding a trailing slash
RewriteRule (.*) http://www.example.com/$1/ [R=301,L]

Replace the broken pipe "" character above with a solid pipe before use; posting on this board modifies the pipe character.

Jim

7:09 pm on Dec 21, 2005 (gmt 0)

10+ Year Member



Hi

I've asked technical support if mod_dir is loaded on the server but the they just sent back a list of files that the server understands and advising me to change the links.

(It's a budget host and I think they outsource support)

I'll try your solution and give it some testing..

Thanks

 

Featured Threads

Hot Threads This Week

Hot Threads This Month