简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM