Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mod-rewrite has revealed itself

I thought that apache mod_rewrite would hide the URL that is being redirected to. i.e. if a user enters http://site.com/iPhone and i've set it up to redirect to http://site.com/search.php?search=iPhone I would have expected that http://site.com/iPhone would still be displayed in the address bar?

.htaccess file is:

<IfModule mod_rewrite.c>
RewriteEngine on 
Options +FollowSymlinks
RewriteBase / 
RewriteRule ^search/(.*) search.php?search=$1 [R]
</IfModule>

Have I got this completely confused?

like image 626
MartinW Avatar asked Dec 08 '25 13:12

MartinW


1 Answers

The [R] modifier causes the response to be redirected to the new URL, rather than handled in-place. Ditch that, and it ought to work (any other problems notwithstanding).

When I'm doing URL rewriting, I like to keep the mod_rewrite cheat sheet from Added Bytes (formerly ILoveJackDaniels) to hand.

like image 121
Rob Avatar answered Dec 11 '25 16:12

Rob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!