.htaccess rewrite problem (object not found)


I’m having problem with my htaccess config. I’ve searched the web for solutions but none of them working for me so far :confused:

I want to rewrite /estate.php?eid=47 for example to this /estate/47

Here is the rewrite code I have now:`RewriteEngine On

RewriteCond %{QUERY_STRING} ^eid=([0-9]*)$
RewriteRule ^estate.php$ /estate/%1? [L]`

But it’s not working. When I open /estate/47 in my browser its says

Object not found!

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.

Error 404

Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30

What sould I change to make it work? Someone was having the same problem but the code I pasted above is worked for him…

That sounds like Apache is catching the request and it isn’t going through the re-write rules.

Check mod_rewrite is actually enabled and allowed to be used.

Do you have any other re-write rules that are working or is this the first?

It has nothing to do with mod_rewrite being on or off. It’s the rewrite rule that is wrong. It should be switched around and have a regex for the last parameter in the first segment. I am not a regex expert so don’t quote me on this, but it should look similar to something like

RewriteRule ^/estate/([0-9]+) /estate.php?eid=$1
RewriteEngine On
RewriteCond %{QUERY_STRING} ^eid=([0-9]*)$
RewriteRule ^/estate/([0-9]+) /estate.php?eid=$1 [L]

I tried it but it’s still not working :confused:

I’m not sure you need the RewriteCond…

1 Like

The htaccess rewrite option may not be working.

Try these tests:


Adding onto this. The rewrite condition is also incorrect. IIRC, rewrite conditions are only used to check if the requested URI is a file, directory, or symbolic link. If it’s one of those 3, then don’t overwrite the URI with the request, but instead, use the actual file.

1 Like

Even if I remove that line and leave just
`RewriteRule ^/estate/([0-9]+) /estate.php?eid=$1 [L] i’ts still not working.

A simple file rewrite is working tho…

RewriteRule ^home index.php [NC,L]

How’s about

RewriteRule ^/estate/([0-9]+)$ /estate.php?eid=$1 [L]

ie missing a $

Just a thought.

Nope. I still got the “Object not fount” page…
It’s driving me crazy…

Edit: To make sure I’ve tried John_Betong’s link and it says mod_rewrite is working. So I am running out of ideas…

OK, just after I posted I found a solution!

The correct rule apparently is

RewriteRule ^estate/([0-9]+) estate.php?eid=$1

Anyway, thanks for your help guys! :wink:

1 Like

It is getting silly! Looking at http://dk.co.nz/seo I wonder if omitting the leading / on both sides will work?

Nope. The right / is necessary but the left is seems not…

The leading / usually tells Apache to use the root of the directory I believe. I remembered messing around with it once. I had the .htaccess in a subdirectory and tried to get the current directory it was in, but couldn’t get it because I kept using the leading slash. I don’t recall if using rewrite base worked, but I remember something got it to work. Maybe I removed the leading slash too.

IIRC Apache changed how the leading slash worked between versions.
@dklynn had something like


so that rules would work with both the older and (at the time) newer Apache versions.

That was quite a while ago so I’m guessing it isn’t an issue these days and now the behavior depends more on RewriteBase



You DO remember correctly: The handling of the leading slash (required by Apache 1.x) was originally ignored (treated as an error) by Apache 2.x. I’ve been informed that Apache 2.x no longer makes that differentiation but have yet to (bother to) confirm.

RewriteBase, IMHO, is too confusing to bother with because it substitutes a relative link into the target. The best write-up I’ve found on this is from StackOverflow:

RewriteBase is only applied to the target of a relative rewrite rule.

Using RewriteBase like this…
RewriteBase /folder/
RewriteRule a.html b.html
is essentially the same as…
RewriteRule a.html /folder/b.html
But when the .htaccess file is inside /folder/ then this this also points to the same target:
RewriteRule a.html b.html
Although the docs imply always using a RewriteBase, Apache usually detects it correctly for paths under the DocumentRoot unless:

  • You are using Alias directives
  • You are using .htaccess rewrite rules to perform HTTP redirects (rather than just silent rewriting) to relative URLs
    In these cases, you may find that you need to specify the RewriteBase.

However, since it’s a confusing directive, it’s generally better to simply specify absolute (aka ‘root relative’) URIs in your rewrite targets. Other developers reading your rules will grasp these more easily.




This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.