JonnoTheDev Posted March 17, 2010 Share Posted March 17, 2010 I'm not the greatest when it comes to more complex rewrite rules so here goes. My directory structure is similar to: (/docs is the document root) docs/index.php docs/file1.php docs/sitefiles/index.php docs/sitefiles/file1.php docs/sitefiles/file2.php And so on. OK, here's the issue. I am trying to backref a url parameter that is sent to the index.php file within the sitefiles subdir for example http://mydomain.com/sitefiles/foobar.com http://mydomain.com/sitefiles/foobar.co.uk The domain at the end is the param I need to capure. The original url is something like: http://mydomain.com/sitefiles/index.php?url=foobar.co.uk So, my .htaccess sits in the sitefiles directory and looks like RewriteEngine On RewriteRule ^([a-z-]+\.[a-z]{2,}\.?[a-z]{0,})$ index.php?url=$1 [L] But when I try this the value contained in $_GET['url'] is index.php. Wierd. Quote Link to comment Share on other sites More sharing options...
premiso Posted March 17, 2010 Share Posted March 17, 2010 Most likely what is happening is the .htaccess is being accessed twice (which is not uncommon) so the first rewrite runs fine, but then it is re-directed and runs through the rules again and since index.php matches your ruleset it is ran again and index.php is now appended. The fix, make the rewrite rule omit .php, or add a rule above it that index.php is left alone like: RewriteEngine On RewriteRule ^index.php$ - [L] # Leave index.php to itself RewriteRule ^([a-z-]+\.[a-z]{2,}\.?[a-z]{0,})$ index.php?url=$1 [L] Not sure if that will work, given the index.php to itself rule, but you should be able to modify it / work from that. Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted March 17, 2010 Author Share Posted March 17, 2010 Oh you are good 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.