htaccess rewrite, how to do this?
Say I have a list of links in a folder, for example:
http://www.site.com/folder/subfolder/subfolderfolder/hello-one.php
http://www.site.com/folder/subfolder/subfolderfolder/hello-two.php
http://www.site.com/folder/subfolder/subfolderfolder/hello-apple.php
http://www.site.com/folder/subfolder/subfolderfolder/hello-pear.php
http://www.site.com/folder/subfolder/subfolderfolder/hello-orange.php
http://www.site.com/folder/subfolder/subfolderfolder/hello-six.php
http://www.site.com/folder/subfolder/subfolderfolder/hello-banana.php
and I wanted them to look like:
http://www.site.com/folder/subfolder/subfolderfolder/hello-one/
http://www.site.com/folder/subfolder/subfolderfolder/hello-two/
and so on..
How would I go about doing it? I only want it done for this folder, for the php files inside it, without doing a rule for each page, can it be done globally for all php files in th开发者_JAVA百科is folder?
Thank you
This might help
Assuming that you want to do this for this folder only
RewriteRule http://www.site.com/folder/subfolder/subfolderfolder/(/*)$
http://www.site.com/folder/subfolder/subfolderfolder/$1.php
The above code will be in one line, I have put on second line for visibility
You can also checkout this tutorial http://corz.org/serv/tricks/htaccess2.php
Try this
RewriteEngine On
RewriteBase /folder/subfolder/subsubfolder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
This will allow you to access http://www.site.com/folder/subfolder/subsubfolder/home-one.php as http://www.site.com/folder/subfolder/subsubfolder/home-one
There are other rules you can create which can setup redirects so that old links will be forced to use the new ones. Just google the issue there are lots of tutorials and help out there. This is one I found - http://www.sicanstudios.com/how-to-remove-php-html-htm-extensions-with-htaccess/
精彩评论