Forum Moderators: phranque
I need to rewrite urls. Some are dynamic and others are static.
I write an .htacess file and I upload this file in the concert folder. But nothing works.
I would like to change dynamic urls like this one:
http://www.example.com/00_AN/03_Catalogue/catalogue_technical.php?ItemSelect=6
redirect to:
http://www.example.com/00_AN/03_Catalogue/product.php
and static pages like:
http://www.example.com/00_AN/03_Catalogue/catalogue_technical_old_product.html
redirect to:
http://www.example.com/00_AN/03_Catalogue/new-product.php
.htaccess file is stored in /03_Catalogue/
Here are the rules that I write:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^ItemSelect=6$
RewriteRule ^/catalogue_technical.php$ http://www.example.com/00_AN/03_Catalogue/product.php? [L,R=301]
RewriteCond %{QUERY_STRING} ^ItemSelect=12$
RewriteRule ^/catalogue_technical.php$ http://www.example.com/00_AN/03_Catalogue/new-product.php? [L,R=301]
redirect 301 /catalogue_technical.html http://www.example.com/00_AN/03_Catalogue/catalogue.php
redirect 301 /catalogue_technical-item.html http://www.example.com/00_AN/03_Catalogue/item.php
Nothing works. I do not know if I can write an .htaccess file with dynamic and static pages in the same file.
I have to keep this ugly folder architecture because pages in it have a good PR to keep
Are you able to tell me what I am doing wrong?
Thank You
That's rather ambiguous, and doesn't tell us much...
Does this simple test rule work?
Options +FollowSymLinks
RewriteEngine on
#
RewriteRule ^foo\.html$ http://www.google.com/ [R=301,L]
> I do not know if I can write an .htaccess file with dynamic and static pages in the same file.
Yes you can, assuming that mod_alias and mod_rewrite are allowed on your server.
> I have to keep this ugly folder architecture because pages in it have a good PR to keep.
To be precise, you may *want* to keep the URL-structure to preserve PR, but you do not have to keep the file-folder structure. You can use mod_rewrite to 'connect' the old URLs to new file locations if you wish. Also, a properly-implemented 301 redirect will pass PR, but it may takes some time --days to months-- for search engines to pass the PR/link-popularity from the old URL to the new. This time delay depends on how frequently your pages are spidered.
Do not mix mod_alias and mod_rewrite directives in the same .htaccess file. Doing so means that you cannot control the order of execution of these directives, since directives are processed on a per-module basis, and module execution order is not controlled by your code order. This module execution order may change if you change hosts or upgrade your server. Therefore, I recommend that if you use mod_rewrite for any redirects or rewrites, that you use it for all redirects as well.
Jim
the test:
Options +FollowSymLinks
RewriteEngine on
#
RewriteRule ^foo\.html$ [google.com...] [R=301,L]
does not works.