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!
I need help with redirect+rewrite url
Moderator: General Moderators
Re: I need help with redirect+rewrite url
Something like this?
The code is probably done wrong, but it's somehting like that I think.
Code: Select all
RewriteEngine On
RewriteCond %{HTTP_HOST} olpage.php?subfolder=12 [nc]
RewriteRule (.*) newpage.php/subfolder/12.html [R=301,L]Re: I need help with redirect+rewrite url
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!
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
what could be wrong with the script above?? it doesn't seem to be working?? thanks!
Re: I need help with redirect+rewrite url
Yea mate, I figured it might be wrongprue_ wrote:what could be wrong with the script above?? it doesn't seem to be working?? thanks!
Just visit this site. It should help you
Re: I need help with redirect+rewrite url
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]-
cpetercarter
- Forum Contributor
- Posts: 474
- Joined: Sat Jul 25, 2009 2:00 am
Re: I need help with redirect+rewrite url
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".
- 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".