I have folder called Pages which contains .php files. I want to convert .php extention to .html for this particular folder on开发者_运维问答ly.I have the .htaccess code to convert the extention
RewriteRule ^([a-z0-9_]+)\.html$ /index.php$1 [NC,L]
But I wanted to make changes for the Particular folder only.
Any ideas???
The .htaccess file relates to the folder in which it placed in and to all the other subfloders.
Therefore, if you want to apply some rewrite rules only to one folder, you need to put an htaccess in that specific folder.
it will change all php files to html files like foo.php
to foo.html
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} (.).php
RewriteRule ^(.*).php $1.html [R=301,L]
RewriteRule ^(.*).html $1.php [L]
You do this by specifying the folder name after the RewriteBase line in your .htaccess as shown below.
RewriteEngine On
RewriteBase /sampleFolder/
RewriteCond %{THE_REQUEST} (.).php
RewriteRule ^(.*).php $1.html [R=301,L]
RewriteRule ^(.*).html $1.php [L]
convert .php extension to .html extension in subdirectory using .htaccess file (convert .php extension to .html extension for all files in particular folder using .htaccess file)
RewriteEngine on
RewriteBase /subdirectory name
Example
RewriteEngine on
RewriteBase /gallery
RewriteCond %{THE_REQUEST} (.*)\.php
RewriteRule ^(.*)\.php $1.html [R=301,L]
RewriteCond %{THE_REQUEST} (.*)\.html
RewriteRule ^(.*)\.html $1.php [L]
精彩评论