Jump to content

htaccess rewriting


anu123

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/85655-htaccess-rewriting/
Share on other sites

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)

 

Link to comment
https://forums.phpfreaks.com/topic/85655-htaccess-rewriting/#findComment-438061
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.