Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- Simple 301 redirect and Wordpress htaccess rules


jdMorgan - 2:10 pm on Aug 11, 2010 (gmt 0)



# Redirect direct client requests for URL-path /<anyfolder>/<index or default>.<php, html, htm, or asp>
# to /<anyfolder>/ and force www and strip the query string to avoid duplicate content.
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(index|default)\.(php|html?|asp)([?#][^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*)(index|default)\.(php|html?|asp)$ http://www.atable.com/$1? [R=301,L]

And still, when I type:

http://www.atable.com/traiteur/coffrets-repas/index.php?utm_source=test

The page comes up without rewriting...

This code is correct, assuming that your rules are ordered correctly and that this code is located in a .htaccess file in the same directory as your robots.txt and sitemap.xml files and the "home page" of your site.

I've found some netlinking goes to a wrong URL: [atable.com...] How would I redirect from this wrong directory?

Modified to accept optional trailing slash:

# Another specific Redirect to WP Homepage
RewriteRule ^a_table_traiteur/?$ http://www.atable.com/? [R=301,L]

Jim


Thread source:: http://www.webmasterworld.com/apache/4182512.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com