I'm attempting to move from
http://domain.site.com/folder/profile.php?name=some_person
towards the cleaner URL
http://sub1.site.com/folder/some_person
During my .htaccess I've the appropriate section:
#Prevent from overriding actual directories and files
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
# Rewrite user URLs
# Input: folder/NAME/
# Output: profile.php?name=NAME
RewriteRule ^folder/(\w+)/?$ profile.php?name=$1
However, if Time passes to
http://sub1.site.com/folder/fred
for example (where fred is really a valid user), I recieve 404 page not found error
What shall we be held doing wrong? Thanks!
Improve your last line to:
RewriteRule ^folder/(\w+)/?$ profile.php?name=$1
BTW, you did not mention the domain title within the result, your present domain and also the result domain will vary, I suppose it is a mis-typo but when you believe it isn't then please try the next rule.
Do this:
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^sub1.site.com$
RewriteCond %{REQUEST_URI} ^/folder
RewriteRule ^/folder/(\w+)/?$ http://domain.site.com/folder/profile.php?name=$1 [QSA]
Note: If you feel domain is same, then just take away the domain in the rule.
You are able to validate your rewrite-rule within this link: http://martinmelin.se/rewrite-rule-tester/