How do I redirect


#1

Hi,

I’m not very familiar with regexp and mod_rewrite, so I was hoping you guys could help me out a little. I’d be extremely grateful if someone could help me out with this one.

I want to use static urls for some webpages. I have read the Dreamhost mod_rewrite documentation as well as the official one, but I still can’t understand how to do this.

I’d like to have the rules in the htaccess and if possible I’d like not to update the PHP files at all, but rather control it all from the htaccess.

A few examples of URL’s and their original files I want to redirect to:

http://www.hotsailsmaui.com/hotrod-classic http://www.hotsailsmaui.com/mast.php?uid=1
http://www.hotsailsmaui.com/hotrod-big-wave http://www.hotsailsmaui.com/mast.php?uid=2
http://www.hotsailsmaui.com/team/diony-guadagnino http://www.hotsailsmaui.com/team.php?uid=1

So how do I do this?
TIA
/Niclas


#2

All you need to know about 301 Redirects. There is a scenario listed that shows what to do in your situation.


#3

Thanks for the link, however I desperately also need info on how to regexp
the url’s.
Also, 301 redirect actually does a redirect. I’d like the URL to show as the above “redirect” URLs and not the dynamic ones. Or have I misunderstood the 301 - does it actually leave the “new” URL in the address field, i.e. www.hotsailsmaui.com/gps rather than the dynamic one?[hr]
Would this work? One row for each link that I want to rewrite of course

Options +FollowSymLinks
RewriteEngine on
RewriteRule sail/gps/ sail.php?uid=1

#4

you need to have requests for one particular url to be redirected to a new location correct? 301 redirect is what you want to do using .htaccess file. the .htaccess file is processed before anything else so even though they typed in one thing, it will automatically go to the new url which will be what is displayed in their address bar. Look at the part of that website about redirecting a single page A to page B to see what the syntax should look like. it is relatively simple.

i think either you or i are confused about what regexp means. to me it means regular expressions which can be utilized for all manner of things that are search related and i am not really clear how that would relate to the problem you are having…


#5

Sort of. I want it to be rewritten as well, so that when the user clicks enters www.hotsailsmaui.com/gps/ in the browser, the address is shown as www.hotsailsmaui.com/gps/ rather than www.hotsailsmaui.com/sail.php?uid=1 when finally the page has been rendered.

[quote=“Ryo-ohki, post:4, topic:55832”]i think either you or i are confused about what regexp means.
[/quote]

:slight_smile: I thought maybe slashes, punctuations etc needed some special expressions in the rewriting.

So, does this work?

Options +FollowSymLinks
RewriteEngine on
RewriteRule sail/gps/ sail.php?uid=1

#6

[quote=“nicky6, post:5, topic:55832”]

Sort of. I want it to be rewritten as well, so that when the user clicks enters www.hotsailsmaui.com/gps/ in the browser, the address is shown as www.hotsailsmaui.com/gps/ rather than www.hotsailsmaui.com/sail.php?uid=1 when finally the page has been rendered.[/quote]

So basically you want clean urls? That is a whole 'nother thing. I guess your inquiry about regexp was valid after all but you will need a php wizard to chime in. My clean urls are done by the cms I use instead of me writing up the code myself so I cannot help you with that.

I’ve never tried it but I don’t think it will. I don’t think 301 redirect is what you are wanting. What you actually have is sail.php?uid=1 right but you want sail/gps/ to show up for SEO purposes right? Google is your friend for information on clean urls.