soycharliente Posted May 25, 2010 Share Posted May 25, 2010 AuthType Basic AuthName "Development Area" AuthUserFile /path/to/.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] RewriteRule ^variable/([0-9]{1,3}) /variable.php?id=$1 [NC] </IfModule> My third RewriteRule is causing my page to kick out a 404 error. Does anyone know why this might be happening? The URLs are formatted correctly in the address bar (example: domain.tld/variable/23). Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/202843-third-rewriterule-creating-404-error/ Share on other sites More sharing options...
cags Posted May 25, 2010 Share Posted May 25, 2010 That would seem to indicate that you don't have a domain.tld/variable.php file. Quote Link to comment https://forums.phpfreaks.com/topic/202843-third-rewriterule-creating-404-error/#findComment-1063072 Share on other sites More sharing options...
soycharliente Posted May 25, 2010 Author Share Posted May 25, 2010 Hmm. I do in fact have a variable.php file in my root directory. I know this for few reasons: 1. I am looking at it via my FTP client. 2. When I hit that page with no passed variables, the page loads with the custom error message programmed on the page saying that it can't find any valid parameters. 3. When I get rid of the RewriteRule and use "the old way," it works fine. The "old way" is ugly to me. I guess I can keep using it until we figure this out. I wish I knew more about .htaccess, so I don't really know any suggestions to make. I'm kind of at a loss. Quote Link to comment https://forums.phpfreaks.com/topic/202843-third-rewriterule-creating-404-error/#findComment-1063077 Share on other sites More sharing options...
cags Posted May 25, 2010 Share Posted May 25, 2010 Changing it to... RewriteRule ^variable/([0-9]{1,3}) /variable.php?id=$1 [NC,R=302] ...will show you in the address bar the URL that it is actually trying to access, this should hopefully point out why it's not being found. Quote Link to comment https://forums.phpfreaks.com/topic/202843-third-rewriterule-creating-404-error/#findComment-1063273 Share on other sites More sharing options...
soycharliente Posted May 26, 2010 Author Share Posted May 26, 2010 I don't see any changes in the address bar. It reads domain.tld/variable/23 and I still receive a 404 error. Quote Link to comment https://forums.phpfreaks.com/topic/202843-third-rewriterule-creating-404-error/#findComment-1063633 Share on other sites More sharing options...
cags Posted May 26, 2010 Share Posted May 26, 2010 Are you sure you are typing in both the rule and the URL correctly? If it's not being rewritten in the address bar then it is not being rewritten at all which means it is not matching that RewriteRule. The only other thing I can think of is it's because you have L in your rewriterule for removing www at the start. Are you attempting to test it by using http://www.domain.tld/variable/23? Try removing the other rules see if it works on it's own, and check spelling. Quote Link to comment https://forums.phpfreaks.com/topic/202843-third-rewriterule-creating-404-error/#findComment-1063658 Share on other sites More sharing options...
soycharliente Posted May 26, 2010 Author Share Posted May 26, 2010 I commented out the first rules and still nothing happens with the Rewrite. I double and triple checked the spelling as well. Here's the latest copy: AuthType Basic AuthName "Development Area" AuthUserFile /path/to/.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] RewriteRule ^variable/([0-9]{1,3}) /variable.php?id=$1 [NC,R=302] </IfModule> It's not a huge deal to have the "pretty" URLs. I can deal with it for now. Quote Link to comment https://forums.phpfreaks.com/topic/202843-third-rewriterule-creating-404-error/#findComment-1063688 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.