Need help with setting up the url rewrite

New to mod_rewrite? This is a good place to start.

it worked

Postby revo » Tue Jul 21, 2009 9:04 pm

I tried, but then I forgot is was a localhost so I had to put in localhost then the website, but it works great now!

Thank you for all your patience and your expertise, I wouldn't know where else to go and I am grateful.
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

updating the indexed links

Postby revo » Sun Sep 06, 2009 1:17 pm

Hello,

Now that I have my modrewrite in place, how can I get the old indexed pages to update in google and yahoo correctly to the new ones with the rewrite url path and links within my website.

thank you again
ed
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

Postby richardk » Sun Sep 06, 2009 3:46 pm

What is your mod_rewrite?

Something like (/old?key=value to /new/value)
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^(.*&)?key=([^&]+)(&.*)?$ [NC]
RewriteRule ^old$ /new/%2? [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby revo » Tue Sep 08, 2009 8:27 am

Yes, I have it setup like that.

1. Do I put that code in my htaccess file right after the url path I already have in there?

2. Also, do I only change the last line in the above code you gave me to fit my path, and leave the rest as you gave it?

RewriteRule ^old$ /new/%2? [R=301,L]

change it to:

RewriteRule ^merch.php?merchant=$1 /merch/merchant/([^/]+/?$ [R=301,L]

3. What do the other lines mean, or do?

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^(.*&)?key=([^&]+)(&.*)?$ [NC]

thank you again
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

Postby richardk » Tue Sep 08, 2009 4:36 pm

1. Do I put that code in my htaccess file right after the url path I already have in there?

I usually put redirects first, but it shouldn't matter (as long as the rules are well written).

2. Also, do I only change the last line in the above code you gave me to fit my path, and leave the rest as you gave it?

RewriteRule ^old$ /new/%2? [R=301,L]

There are three things you must change: "old", "key" and "new" from the old URL /old?key=value to /new/value.

RewriteRule ^merch.php?merchant=$1 /merch/merchant/([^/]+/?$ [R=301,L]

That's nothing like the example.

Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^(.*&)?merchant=([^&]+)(&.*)?$ [NC]
RewriteRule ^merch\.php$ /merch/merchant/%2? [R=301,L]


3. What do the other lines mean, or do?

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^(.*&)?key=([^&]+)(&.*)?$ [NC]

The first condition makes it only match requests from the browser not internal requests. The second condition matches the query string variable.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby revo » Mon Sep 21, 2009 1:11 pm

I have this so far in my htaccess:

Code: Select all
Options +FollowSymLinks -MultiViews

RewriteEngine On

RewriteRule ^merch/merchant/([^/]+)/?$ merch.php?merchant=$1 [QSA,L]


and if I would like google and yahoo to keep my pages indexed and keep my rankings would my final updated htaccess file look like this?

Code: Select all
Options +FollowSymLinks -MultiViews

RewriteEngine On

RewriteRule ^merch/merchant/([^/]+)/?$ merch.php?merchant=$1 [QSA,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^(.*&)?merchant=([^&]+)(&.*)?$ [NC]
RewriteRule ^merch\.php$ /merch/merchant/%2? [R=301,L]


thank you
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

Postby richardk » Tue Sep 22, 2009 9:30 am

It should be fine, unless the site is in a sub directory, then /merch/merchant/%2? would need to be /the_sub_directory/merch/merchant/%2?.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby revo » Wed Sep 23, 2009 1:14 pm

Thank you,

Ok I will be working on it, meantime if I wanted to add another one for my categories would I have it like so:


Options +FollowSymLinks -MultiViews

RewriteEngine On

RewriteRule ^merch/merchant/([^/]+)/?$ merch.php?merchant=$1 [QSA,L]
RewriteRule ^category/categoryid/([^/]+)/?$ category.php?categoryid=$1 [QSA,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^(.*&)?merchant=([^&]+)(&.*)?$ [NC]
RewriteRule ^merch\.php$ /merch/merchant/%2? [R=301,L]
RewriteRule ^category\.php$ /category/categoryid/%2? [R=301,L]

and this way my categories will be permanently known to google and yahoo?
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

Postby richardk » Fri Sep 25, 2009 12:06 pm

No. You must repeat the whole rule set and change three things
Code: Select all
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^(.*&)?key=([^&]+)(&.*)?$ [NC]
RewriteRule ^old$ /new/%2? [R=301,L]

There are three things you must change: "old", "key" and "new" from the old URL /old?key=value to /new/value.


Something like
Code: Select all
Options +FollowSymLinks -MultiViews

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^(.*&)?merchant=([^&]+)(&.*)?$ [NC]
RewriteRule ^merch\.php$ /merch/merchant/%2? [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^(.*&)?categoryid=([^&]+)(&.*)?$ [NC]
RewriteRule ^category\.php$ /category/categoryid/%2? [R=301,L]

RewriteRule ^merch/merchant/([^/]+)/?$ merch.php?merchant=$1 [QSA,L]
RewriteRule ^category/categoryid/([^/]+)/?$ category.php?categoryid=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby revo » Fri Sep 25, 2009 6:04 pm

Great ! thank you :D , I will be working on them both.
revo
 
Posts: 34
Joined: Fri Feb 13, 2009 2:02 pm

PreviousNext

Return to Beginner's Corner

Who is online

Users browsing this forum: Google [Bot] and 3 guests

cron