![]() |
Help with .htaccess RewriteRule regex
There's a page on my website to view a user's profile. The username is passed in through the URL and since that's all that's needed in the URL I simply pass it as the query string, such as
http://example.com/profile/?manwithahatI thought it would be nice to get rid of the question mark in the URL by using the Apache RewriteEngine, so the URL could be like this http://example.com/profile/manwithahatBut I am having trougble with the regular expression that RewriteRule needs. I thought I could use - but this causes an internal server error.Doing some testing I found that this will pass through a number the way I need it to - so that if the URL is http://example.com/profile/123456 then in PHP the $_SERVER['QUERY_STRING'] value becomes 123456. From this test I know that the overall structure of the RewriteRule is correct, it's just the regular expression that needs fixing.What should be used instead of ^(.*)$ ? |
could you use
RewriteEngine on RewriteRule ^profile/(.*).html$ /index.php?username=$1 [QSA,L] |
That doesn't fit my specific case.
|
| All times are GMT +1. The time now is 05:19 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.