mageDev0688
mageDev0688

Reputation: 566

htaccess change files extension from .php to .html

I have created the redirect rule for seo friendly URL's. I want to remove the .php URL from all pages and requests.

I have tried with the below code but it not working:

Options -Multiviews

Options +FollowSymLinks

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^special-offers.html$ special_offers.php
RewriteRule ^([a-zA-Z0-9-/]+).html$ offer_detail.php?url=$1


RewriteRule ^sear_search.html$ search.php

ErrorDocument 404 /404page.php

I already using this rules in other project and the URL's are working fine, but now it's not workin.

Upvotes: 1

Views: 609

Answers (1)

anubhava
anubhava

Reputation: 784898

Have it this way:

ErrorDocument 404 /404page.php
Options +FollowSymLinks -Multiviews

RewriteEngine On

RewriteRule ^special-offers.html$ special_offers.php [L,NC]

RewriteRule ^sear_search\.html$ search.php [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z0-9/-]+)\.html$ offer_detail.php?url=$1 [L,NC,QSA]

Your RewriteBase / directive is routing it to site root directory instead of current directory.

Upvotes: 2

Related Questions