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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.