0
votes

I have a simple RewriteRule below that's working fine on my local machine but it doesn't work when I uploaded to my live server.

Error:

Not Found The requested URL /redirect:/jobs.php/1/field-engineer.php/1/field-engineer.php was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

.htaccess:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.htm $1.php [NC]
RewriteRule jobs/([0-9]+)/(.*)/ jobs.php?id=$1 [NC]
RewriteRule testimonial-details/([0-9]+)/(.*)/ testimonial-details.php?id=$1 [NC]
RewriteRule testimonials/([0-9]+)/(.*)/ testimonials.php?id=$1 [NC]

Any help will be gladly appreciated.

1

1 Answers

-1
votes

Did you check if your rewrite module was loaded? Btw you should check it in your htaccess:

<IfModule mod_rewrite.c>
// your rewrite stuff here
</IfModule>

Edit:

Maybe this could help. Try to set the PT flag to your first rewrite rule

RewriteRule ^(.*)\.htm $1.php [NC,PT]

That will tell the engine to make a clean second path on the generated URL. Because there is a weird behaviour according to you rule.

The url

jobs/1/civil-engineer.html is rewritten as jobs/1/civil-engineer.php

but the following rule

jobs/([0-9]+)/(.*)/ is waiting to for an url like jobs/1/civil-engineer.php/

I did some testing but removing the '/' only avoided certain errors, but the behavious was still weird. The only way i found was to add the PT flag or to change the rule for

RewriteRule jobs/([0-9]+)/(.*)\?php jobs.php?id=$1