anu123 Posted January 12, 2008 Share Posted January 12, 2008 My issue is when the user types the url www.abc.com/xyz the page should be redirected to www.abc.com/broker/index.php?url=xyz.The subdmain name 'xyz' is dynamic which is passed as argument in the redirection page ie here index.php. How will i write the htaccess rewriting for this need.can anyone help? Quote Link to comment https://forums.phpfreaks.com/topic/85655-htaccess-rewriting/ Share on other sites More sharing options...
Ken2k7 Posted January 12, 2008 Share Posted January 12, 2008 xyz isn't a subdomain. At least not in that example. ??? Quote Link to comment https://forums.phpfreaks.com/topic/85655-htaccess-rewriting/#findComment-437123 Share on other sites More sharing options...
Wuhtzu Posted January 12, 2008 Share Posted January 12, 2008 Wrong board... but # URL rewriting RewriteEngine on RewriteBase / RewriteRule ^([a-zA-Z0-9]+)$ broker/index.php?url=$1 Quote Link to comment https://forums.phpfreaks.com/topic/85655-htaccess-rewriting/#findComment-437126 Share on other sites More sharing options...
anu123 Posted January 12, 2008 Author Share Posted January 12, 2008 Yes, that is what i want.But one thing more, the page url should be displayed as www.abc.com/xyz and not as www.abc.com/broker/index.php Quote Link to comment https://forums.phpfreaks.com/topic/85655-htaccess-rewriting/#findComment-437133 Share on other sites More sharing options...
Wuhtzu Posted January 12, 2008 Share Posted January 12, 2008 The rewrite rule does what you want .... and if it for some reason does not please tell us exactly what's wrong. Because I wrote the rule to do what you said... Quote Link to comment https://forums.phpfreaks.com/topic/85655-htaccess-rewriting/#findComment-437466 Share on other sites More sharing options...
madmax Posted January 13, 2008 Share Posted January 13, 2008 I hope you don't mind me adding this... The rule given required a [L] but I suspect you may have added [L,R] (Last rule/redirect) out of habit. If you change to just [L] it should work (discounting any interacting rules) Tested on my local machine OK using the httpd.conf version #http.conf version RewriteEngine on #Uncomment line below for htaccess to set RewriteBase to root #RewriteBase / #remove / ----------- and / below for .htaccess RewriteRule ^/([a-zA-Z0-9-]+)$ /broker/index.php?url=$1 [L] #.htaccess version RewriteEngine on RewriteBase / RewriteRule ^([a-zA-Z0-9-]+)$ broker/index.php?url=$1 [L] #.htaccess version with redirected link visible RewriteEngine on RewriteBase / RewriteRule ^([a-zA-Z0-9-]+)$ broker/index.php?url=$1 [L,R] Also see http://www.ilovejackdaniels.com/cheat-sheets/mod_rewrite-cheat-sheet/ Specifically mod_rewrite_cheat_sheet.pdf (no direct-link request honoured) Quote Link to comment https://forums.phpfreaks.com/topic/85655-htaccess-rewriting/#findComment-438061 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.