user3580094
user3580094

Reputation: 1

Rewrite Rule Not working .htaccess

I have the following URL which I am trying to make SEO friendly URL. I tried a few of the online rewrite validators and they validated perfect for the rules which I have written in .htaccess, but it's still not working when uploaded to my server. Any help is really appreciated.

I want http://example.com/deal/de3582c47f/ to be redirected (without actually changing the URL for the end user) to http://example.com/dealinfo.php?offerid=de3582c47f.

There are multiple sites deployed in the common root directory. Below are my .htaccess rules:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com
RewriteRule ^deal/(.+)/$ dealinfo.php?offerid=$1 [L]

I am not sure where I am going wrong?

Upvotes: 0

Views: 507

Answers (1)

Erwin
Erwin

Reputation: 183

actually.. the RewriteCond rules you have, only tell the latest rule, that they should work on those domains.

does the virtualhost definition has AllowOverride all?

but i would go with:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?example.com [NC]
RewriteRule ^deal/(.+)/ /dealinfo.php?offerid=$1 [L]

i added a slash at the begining of dealinfo.php, so it will look on documentRoot folder defined on the virtualhost for your domain, instead of the actual 'fake' folder.

Upvotes: 1

Related Questions