Forum Moderators: phranque

Message Too Old, No Replies

htaccess redirect problem

htaccess redirect problem

         

ragavbala

12:28 pm on Jun 4, 2010 (gmt 0)

10+ Year Member



hi
I am having a htaccess URL
1.RewriteRule ^exemples-demandes-devis-([^/\.]+)-([^/\.]+).html?$ exemples-subcat-demandes-devis.php?cate=$1&subcat=$2 [R=301]

now i am going to write the URL
2.RewriteRule ^exemples-demandes-devis-travaux-Abri_Garage.html$ exemples-demandes-devis-travaux-Abri_Pergola_Garage.html [R=301]


while i enter the URL second one
exemples-demandes-devis-travaux-Abri_Garage.html
it is redirecting to the
exemples-subcat-demandes-devis.php?cate=$1&subcat=$2 which one written globally
i have to redirect the url to the second one
Please tell me the solution it is very urgent

Thanks in Advance

jdMorgan

2:36 pm on Jun 4, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That would indicate that the rules are in the wrong order, and should be reversed.

But there seems to be a more-serious problem here in that your first rule *should NOT* be a redirect. If it is a redirect, it defeats the entire purpose of using search-friendly keyword-URLs.

This may need some adjustment to work with your site, but a better approach would be:

# Externally redirect specific incorrect URL to add "_Pergola"
RewriteRule ^exemples-demandes-devis-travaux-Abri_Garage\.html$ http://example.com/exemples-demandes-devis-travaux-Abri_Pergola_Garage.html [R=301,L]
#
# Internally rewrite search-friendly URL-path requests to script filepath plus query
RewriteRule ^exemples-demandes-devis-([^/\-]+)-([^/.\-]+)\.html?$ exemples-subcat-demandes-devis.php?cate=$1&subcat=$2 [L]

Note the distinctions between external redirects and internal rewrites. An external redirect is a URL-to-URL translation, while an internal rewrite is a URL-to-filepath translation; URLs and filepaths are not at all the same thing...

Note also minor improvements and corrections to patterns and character-escaping.

Jim

ragavbala

12:50 pm on Jun 7, 2010 (gmt 0)

10+ Year Member



Hi
I tried with the your method , but it is not working ,
Do you have any other ideas to do this?

ragavbala

12:51 pm on Jun 7, 2010 (gmt 0)

10+ Year Member



do you know any good sites for rewriting URL for htaccess

jdMorgan

2:25 pm on Jun 7, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ignoring the insinuation, I have to ask... Did you delete your browser cache before testing the new code?

What, specifically, "is not working?" :
How do you test?
What were the results?
How did those results differ from your expectations?

Jim

g1smd

8:45 pm on Jun 7, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



do you know any good sites for rewriting URL for htaccess

[httpd.apache.org...] and, err, [webmasterworld.com...]