soycharliente Posted April 28, 2010 Share Posted April 28, 2010 I thought by adding a rewrite condition to my htaccess file, I could generate some better looking URLs. When I have the following rewrite applied RewriteRule ^state/([a-z]{2}) http://domain.tld/index.php?state=$1 [NC] and try to visit the "better looking" URL, it forwards to the "ugly" one. Am I missing something? Here's the whole file too: AuthType Basic AuthName "Development Area" AuthUserFile /path/to/the/file/.htpasswd Require valid-user <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.domain.tld [NC] RewriteRule ^(.*) http://domain.tld/$1 [L,R=301] RewriteRule ^state/([a-z]{2}) http://domain.tld/index.php?state=$1 [NC] </IfModule> Quote Link to comment https://forums.phpfreaks.com/topic/200066-url-rewrite-mask/ Share on other sites More sharing options...
cags Posted April 28, 2010 Share Posted April 28, 2010 It's because you included the full URL in the rewritten path, not a server path. AuthType Basic AuthName "Development Area" AuthUserFile /path/to/the/file/.htpasswd Require valid-user <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.domain.tld [NC] RewriteRule ^(.*) http://domain.tld/$1 [L,R=301] RewriteRule ^state/([a-z]{2}) /index.php?state=$1 [NC] </IfModule> Quote Link to comment https://forums.phpfreaks.com/topic/200066-url-rewrite-mask/#findComment-1050094 Share on other sites More sharing options...
soycharliente Posted May 25, 2010 Author Share Posted May 25, 2010 Been out of town. Works! Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/200066-url-rewrite-mask/#findComment-1063024 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.