Forum Moderators: phranque

Message Too Old, No Replies

file and folder with the same name

can I redirect /widget to /widget.html?

         

Reid

12:26 am on Oct 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



can I redirect /widget to /widget.html?

I have an HTML page widget.html, maybe some JAVA or CSS but nothing else, it is in the root directory. There is also a folder named /widget in the root directory, The problem is that people type in mysite.com/widget (they forget the .html) and they get a file listing for the folder /widget. Is a simple redirect possible here or would it cause other problems? Or am I better off just putting in the effort to rename the folder?

jdMorgan

1:00 am on Oct 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If that's a popular page, I'd definitely use a multi-file search-and-replace utility to rename the page or the directory. There are several free ones you can find with a search, and they'll fix a problem like this, changing hundreds of links on hundreds of pages in seconds.

Do take into account the search engine rankings of the pages in that subdirectory versus the ranking of the one "widget" page when doing this, since different URL = different page in the search engines' eyes...

Also, you can configure your server to deny directory listings for cases like this, using the


Options -Indexes

directive in an .htaccess placed in the /widget subdirectory.

Jim

Reid

9:13 pm on Oct 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ok the problem I have is that a brochure went out advertising mysite/widgets as the URL it should have been mysite/widgets.html
so people are getting the directory listing instead of the page, I guess thats better than a 404.

would I be able to redirect mysite/widgets to mysite/widgets.html without causing any problems regarding the the folder mysite/widgets? so that anyone typing the URL mysite/wigets will not get that folder (which exists) but will instead get the page widgets.html in the root folder?

thanks for your patience

jdMorgan

1:47 am on Oct 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, and that's a fairly simple exercise. See the examples in the URL Rewriting Guide cited in our forum charter. This is simply a matter of using a sufficiently-specific regular expressions pattern for the RewriteRule, so that only specific requested URL-paths get rewritten.

After reviewing the Apache forum charter [webmasterworld.com], the documents cited therein, and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com], take a shot at the code and post your best effort. We'll be glad to help you get it working.

Jim