Connecting Tech Pros Worldwide Forums | Help | Site Map

htaccess redirect + rewrite

Member
 
Join Date: Jul 2007
Posts: 40
#1: Nov 16 '08
hello,
I have been looking for a solution to redirect the users to the correct urlrewrite page but I cant come up with anything thats working.

This is how I rewrite it now:
Expand|Select|Wrap|Line Numbers
  1. RewriteRule ^(search)/(.*)$ search.php?id=$2 [L]
so basically the user could search like this:
search/something

the problem is that I need to redirect them from search.php?id=something to search/something

I tried to add [R=301] but that didn't work, I didn't have any luck with redirect 301 either.

Any ideas on how to get this fixed?

pbmods's Avatar
Site Moderator
 
Join Date: Apr 2007
Location: Texas
Posts: 5,435
#2: Nov 16 '08

re: htaccess redirect + rewrite


Heya, Gozil.

Do a print_r($_SERVER) for each URL and see which value you can use to find out which URL the User typed in.

If I remember correctly, there are a couple of URL-related $_SERVER variables that mod_rewrite does not affect.
Member
 
Join Date: Jul 2007
Posts: 40
#3: Nov 16 '08

re: htaccess redirect + rewrite


But isn't there a way to redirect them from the .htaccess file at once?
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,949
#4: Mar 5 '09

re: htaccess redirect + rewrite


Try changing the flag to [R], although I'm not understanding your problem fully.
Reply