Welcome to WebmasterWorld Guest from 54.204.74.171

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Rewrite example/ to example.html

   
4:39 pm on Dec 17, 2008 (gmt 0)

5+ Year Member



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?

4:54 pm on Dec 17, 2008 (gmt 0)

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



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.

4:56 pm on Dec 17, 2008 (gmt 0)

10+ Year Member



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:12 pm on Dec 17, 2008 (gmt 0)

5+ Year Member



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 :-)