Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I need to change something like this:

www.mydomain.com/www.otherdomain.com

to this:

www.mydomain.com/index.php?co=www.otherdomain.com

Using mod_rewrite I came up with this:

RewriteRule ^(.*.)+$ index.php?co=$1 [L]

However it is only returning "index.php" for the co parameter and not "www.otherdomain.com" like I want it to.

Thanks for any help!

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Try this instead:

RewriteCond %{REQUEST_URI} !^/index\.php
RewriteRule (.*) index.php?co=$1

The RewriteCond checks that the requested path does not already begin with "/index.php" (without this check an infinite loop will occur). And, if not, the RewriteRule then rewrites everything in the request to the index.php path you need.

share|improve this answer
    
That worked... Thanks! –  Joe Patterson Jun 17 '13 at 19:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.