tim
tim

Reputation: 3903

simple mod_rewrite keeps causing 404

I'm desperate... this test rule here works just fine so the server is certainly configured properly. It refreshes the page as expected.

RewriteRule /hello.htm /index.htm [R]

But I'm trying to simply refresh the page from example.com/123 to example.com/index.htm?id=123. I thought I could do it like this:

RewriteRule ^/([0-9]+)$ /index.htm?id=$1 [R]

But it just won't work. Get 404 all the time, checked my logs, nothing useful in there.

I'm HORRIBLE at this and hope to get some help.

Upvotes: 1

Views: 323

Answers (2)

tim
tim

Reputation: 3903

Well, I finally figured out my problem, and given the number of questions re: 404 issues I imagine it's relatively common.

My server is shared, i.e. I have hosting with one of the usual larger companies that use virtual servers, etc...

As a result, I needed to add the full domain name to my redirect. so instead of doing /index.htm?id=$1 I had to do http://www.example.com/index.htm?id=$1

And presto, it worked.

Upvotes: 1

Riz
Riz

Reputation: 368

Give this a try should work for you

RewriteRule ^([0-9]+)$ /index.html?id=$1 [NC,R=301]

Upvotes: 0

Related Questions