homepage Welcome to WebmasterWorld Guest from 23.20.91.134
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Trailing slash redirect
Doesn't seem to be implemented
Snookered




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

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

 

jdMorgan




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

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

Snookered




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

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

jdMorgan




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

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

Snookered




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved