Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Trailing slash redirect

Doesn't seem to be implemented



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

10+ Year Member


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?



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?



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

10+ Year Member

Sorry that was typo it should be


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.



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.



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

10+ Year Member


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..



Featured Threads

Hot Threads This Week

Hot Threads This Month