Forum Moderators: phranque
First I'll tell what i want: if I enter subdomain.example.com/2/ I want it to be rewritten to /script.php?user=subdomain&page=2
I am using this .htaccess:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST}!^www [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com [NC]
RewriteRule ([0-9]+)? /script.php?user=%1&page=$1 [R=301,L]
This works fine, but i don't want it to be redirected, I want to keep the original url (subdomain.example.com/2/). But when I remove the R flag from the rewriterule I get a 500 error, what am I doing wrong?
Thanks!
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www
RewriteCond %{HTTP_HOST} ^([^.]+)\.example\.com
RewriteRule ^([0-9]+)/$ /script.php?user=%1&page=$1 [L]
Also, the [NC] flags should not be needed, as domains are lowercase-only as sent by browsers.
If you do not have access to your error log file, you need a better host. I cannot recommend using mod_rewrite on a server that limits your access to basic troubleshooting tools.
See the regular-expressions tutorial cited in our charter [webmasterworld.com] for more information on regular-expressions pattern matching.
Jim