How can I set up my htaccess to do this?
I am trying to s开发者_JAVA技巧et up my htaccess file to perform these redirections:
http://www.mysite.com/about should link to http://www.mysite.com/content/pages/about.php
http://www.mysite.com/login should link to http://www.mysite.com/content/pages/login.php
http://www.mysite.com/prices should link to http://www.mysite.com/content/pages/prices.php
Thanks
To only redirect URLs you have provided you can use this kind of rule (you can add other pages to the list of you need):
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^(about|login|prices)$ /content/pages/$1.php [L]
To redirect ALL non-existing pages to /content/pages/PAGE_NAME.php
, you can use this rule:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# do not do anything for already existing files (like images/css/js etc)
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .+ - [L]
# redirect everything else
RewriteCond %{REQUEST_URI} !^/content/pages/
RewriteRule ^(.+)$ /content/pages/$1.php [L]
NOTES: You need to place these rules into .htaccess in website root folder. If placed elsewhere some small tweaking may be required.
精彩评论