galvin Posted October 28, 2011 Share Posted October 28, 2011 Just curious what would cause a URL "hidden" by mod_rewrite to SOMETIMES show in the browser? For example, I have this code below in my htaccess file which rewrites www.example.com/whatever to www.example.com/play.php?url=whatever. 95% of the time, when I enter www.example.com/whatever into the browser, it stays that way in the location bar. But every once in a while, it will change to show the "hidden" URL of www.example.com/play.php?url=whatever. I'm new to mod_rewrite so maybe this is normal? Or should it never do that? If the latter, any idea what possibly might cause it to happen? <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^([^/\.]+)/?$ play.php?url=$1 [L] </IfModule> Quote Link to comment Share on other sites More sharing options...
trq Posted October 28, 2011 Share Posted October 28, 2011 Maybe your clicking a link to the ugly url? Quote Link to comment Share on other sites More sharing options...
galvin Posted October 28, 2011 Author Share Posted October 28, 2011 Not that I remember. It's always been me copying the good URL and pasting it into a browser location bar and it changes to the bad one. Weird. Not ruling out me doing something stupid but I don't think so . Anyway just curious if this was a known issue. Not a huge deal. Quote Link to comment Share on other sites More sharing options...
trq Posted October 28, 2011 Share Posted October 28, 2011 The rewrite rule you posted could not possibly be responsible for doing what you have described. Quote Link to comment Share on other sites More sharing options...
cags Posted October 30, 2011 Share Posted October 30, 2011 header redirect in the actual php file? Quote Link to comment Share on other sites More sharing options...
galvin Posted November 6, 2011 Author Share Posted November 6, 2011 Ok, I found that when I enter the www version of my domain, it shows the "clean" url. But without www, it shows the "ugly" url. For example, entering "www.mydomain.com/whatever" keeps that same, clean URL in the address bar. But if I leave off the "www" and enter just "mydomain.com/whatever", it changes to "www.mydomain.com/play.php?url=whatever" So I think that means the problem has to be with my mod_rewrite rules in my htaccess files, right? This is how I had them... <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^([^/\.]+)/?$ play.php?url=$1 [L] </IfModule> #sending all non-www requests to www Options +FollowSymlinks RewriteEngine on rewritecond %{http_host} ^mydomain.com [nc] rewriterule ^(.*)$ http://www.mydomain.com/$1 [r=301,nc] I then changed it by putting the www redirect rules FIRST, but it didn't help. Something's got to be missing/wrong in my rules above that is causing non-www versions to show the ugly URL. Anyone see the problem? Quote Link to comment 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.