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

Apache Web Server Forum

Rewrite example/ to example.html

5+ Year Member

Msg#: 3809603 posted 4:39 pm on Dec 17, 2008 (gmt 0)

Sorry if this has been answered before, I tried searching for it, but I am not sure what to search for...

Anyway, I had a website with urls like www.domain.org/example/

Recently I changed the site completely, and now I have some ulrs that read www.domain.org/example.html.
The problem is, the old urls (via Google) simply show the page but without styling. So I want to rewrite or redirect the example/ urls to example.html. How do i do this?

I tried:

Redirect [domain.org...] [domain.org...]

but this doesn't work?



WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

Msg#: 3809603 posted 4:54 pm on Dec 17, 2008 (gmt 0)

That's because you have misunderstood the syntax to use for a redirect.

However, you don't seem at all clear as to whether you need a rewrite or a redirect - and they are completely different things.

You need to make sure that the content is directly available at only one URL and that all other variations issue a redirect.

In some cases you may also need a rewrite to connect the URL request to the internal filename for that content, when the tail of the URL differs from the actual filename.

If styling is not being seen, then it is likely that you need to begin the links to the stylesheet with a / and state the full folder-path to the stylesheet as it is the browser that resolves the stylesheet location based on the URL for the current HTML page.


10+ Year Member

Msg#: 3809603 posted 4:56 pm on Dec 17, 2008 (gmt 0)

Test, if RedirectMatch fits your needs. But make sure, you're specifying the statuscode 301:

RedirectMatch 301 ^/([^/]+)/$ http://www.example.com/$1.html

What went wrong with your redirect directive? the first argument must be an URl-path, i.e. /example/ only


5+ Year Member

Msg#: 3809603 posted 5:12 pm on Dec 17, 2008 (gmt 0)

Thank you Caterham, it worked.

The problem was that the site used to be in Wordpress. I decided I didn't need a CMS and redid the site "static". I only noticed the problem after I was done.

Anyway, it is working now. Thanks again.

@g1smd: Yes, if I was unable to find a htaccess solution my next option was to rewrite the css-urls, but I was hoping I wouldn't have to. And I don't :-)

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