I'm using PHP's RouteMap and want to clean up the URL.
The URL's come in the form of:
http://localhost/subfolder/index.php?controller/method/arg1
开发者_StackOverflow中文版How would I convert this to:
http://localhost/subfolder/controller/method/arg1
haven't tested it, but I think you will want the following:
RewriteRule ^/subfolder/controller/(method/.*)$ /subfolder/index.php?controller/$1
You can try this in your httpd.conf file:
#start your engine
RewriteEngine on
#add www. for any url, not what you asked for, but kinda helpful SEO-wise
RewriteCond %{HTTP_HOST} ^mypage\.com
RewriteRule ^(.*)$ http://www.mypage.com$1
#rewrite stuff
RewriteRule ^/subfolder/(controller/method/arg1)/?$ /index.php?$1
That should work. I would change the last line, tho:
RewriteRule ^/subfolder/(controller/method/arg1)/?$ /index.php?p=$1
Now, before you restart apache, try to test if the config file is ok.
user$ apachectl configtest
And that's about it.
Hope it helps.
Cheers
RewriteRule ^products/([0-9][0-9])/$ /productinfo.php?prodID=$1 [R]
RewriteRule ^products/([0-9][0-9])$ /products/$1/
Multiple redirects in the same .htaccess file can be applied in sequence, which is what this does
精彩评论