Jump to content

Recommended Posts

Posted

Some sites create dynamic urls, like perhaps http://www.foo.com/cow'>http://www.foo.com/cow Where "cow" is not a file or a directory, but is redirected and the page is dynamically generated. I've looked in the usual places, but I can't figure out how this is done. If someone type's http://www.foo.com/cow , and I'm foo.com, how would I get that redirected to, say, http://www.foo.com/script.php?id=cow ? I think the answer lies in the .htaccess file, but I'm not sure.

 

help?

Posted

Welcome to the forums zethon :)

 

You are correct, it's done in the .htaccess

 

You can either do a single redirect

>redirect 301 /cow http://www.foo.com/script.php?id=cow

 

or a general redirect (in this case, for all files except "elephant"

 

>RewriteEngine on
RewriteBase   /
# don't rewite for elephant
RewriteCond %{REQUEST_URI} !^/elephant
# rewrite for eveything else ...
RewriteRule ^(.*) /script.php?id=$1 [L]

Join the conversation

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

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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