Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to redirect php page to html using htaccess?

I have read htacess condition from this url Htacess Url

but can't understand how to solve the problem when the condition is solve in htacess.

My main question is how to change the all php page into the html format any where to click the the PHP link then open the

Just Like Example : This php url any where to open that the redirect to the html page what i set the condition in htacess PHP Url

http://www.localhost/efundoo.com/products.php?product=Touch-Screen-Digitizer-For-Videocon-A10

And change into the

http://www.localhost/efundoo/public_html/products/lcd-display-for-samsung-galaxy-star-pro-gt-s7262.html

My htacess condition is following

1) This is running fine

RewriteRule ^([^/]+)/([^/]+)/?$ index.php?user=$1&type=$2  [NC,QSA]

2) but when i try this condition Page are not open

RewriteCond %{THE_REQUEST} \s/+.+?\.php\?user=([^\s&]+)&type=([^\s&]+)\s [NC]
RewriteRule . %1/%2.html? [R=301,L]
RewriteRule ^([^/]+)/([^./]+)/.html$ page.php?user=$1&type=$2 [NC,L,QSA]
like image 452
Nancy Avatar asked Jul 07 '26 09:07

Nancy


1 Answers

Try this in .htaccess,

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

.htaccess file:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>

.html to .php

RewriteEngine On
RewriteRule ^(.*)\.html$ $1.php [L]

.php to .html

RewriteCond %{THE_REQUEST} \ /(.+)\.php
RewriteRule ^ /%1.html [L,R=301]

config.php file:

$config['index_page'] = ''; //specify your html file
like image 175
Sagar Naliyapara Avatar answered Jul 09 '26 23:07

Sagar Naliyapara



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!