Page 1 of 1
I need help with redirect+rewrite url
Posted: Sun Jul 26, 2009 9:56 pm
by prue_
how to write .htaccess??? to redirect some url then rewrite it into SEO friendly url??
e.g olpage.php?subfolder=12 to newpage.php/subfolder/12.html
thanks a lot!
Re: I need help with redirect+rewrite url
Posted: Sun Jul 26, 2009 10:06 pm
by insight
Something like this?
Code: Select all
RewriteEngine On
RewriteCond %{HTTP_HOST} olpage.php?subfolder=12 [nc]
RewriteRule (.*) newpage.php/subfolder/12.html [R=301,L]
The code is probably done wrong, but it's somehting like that I think.
Re: I need help with redirect+rewrite url
Posted: Sun Jul 26, 2009 10:11 pm
by prue_
if i have a lot of page to redirect and rewrite, will I just have to add all of them??
if I'm not mistaken, is this the one for redirect???
RewriteCond %{HTTP_HOST} olpage.php?subfolder=12 [nc]
and this one for rewrite???
RewriteRule (.*) newpage.php/subfolder/12.html [R=301,L]
Thanks!
Re: I need help with redirect+rewrite url
Posted: Sun Jul 26, 2009 10:24 pm
by prue_
what could be wrong with the script above?? it doesn't seem to be working?? thanks!
Re: I need help with redirect+rewrite url
Posted: Sun Jul 26, 2009 11:10 pm
by insight
prue_ wrote:what could be wrong with the script above?? it doesn't seem to be working?? thanks!
Yea mate, I figured it might be wrong

.
Just visit this site. It should help you
Re: I need help with redirect+rewrite url
Posted: Sun Jul 26, 2009 11:43 pm
by prue_
I used the ff. code but it's not working... what's wrong with this code?? thanks!
Code: Select all
# Enable Rewrite Engine
RewriteEngine on
#Redirect old.php to new.html
Redirect 301 /old.php long_ugly_url.php?something=yes
#Create friendly URL
RewriteRule ^something_short.html$ long_ugly_url.php?something=yes [L]
Re: I need help with redirect+rewrite url
Posted: Mon Jul 27, 2009 2:16 am
by cpetercarter
Before trying to get the code right, have you checked that you can in fact use an .htaccess file on your server? Two things are important:
- the Apache module mod_rewrite must be loaded
- the relevant Apache configuration file must permit "override"
You can use phpinfo() to check whether mod_rewrite is loaded - look for the "loaded modules" box under "apache2handler".
A good way to check if Apache is able to read .htaccess files is to write a garbage file (put a random selection of characters into it) and load it to your site. You should get an "internal server error" message when you try to access the site. If you don't, Apache isn't reading the .htaccess file.
You need root access to the server to load mod_rewrite or to enable "override".