Forum Moderators: phranque
New:
news.html
ftopict-1095.html
.htaccess:
RewriteRule ^news.html modules.php?name=News [L]
RewriteRule ^ftopic(t¦p)-([0-9]*).html modules.php?name=Forums&file=viewtopic&$1=$2 [L]
But promblem is Google index both old & new Urls and make MANY duplicate content,I want to clear old urls from google, I know the solution is 301 redirect but i can't figure the correct syntax in htaccess.for example follownig line wont work and return 200.ok status.
RewriteRule ^modules.php?name=News [mydomain.com...] [R=301,L]
Here's one that has a short, clear explanation:
[webmasterworld.com...]
Aside from that, you might also want to read through the Apache documentation for the exact syntax for RewriteCond and RewriteRule, in addition to examining the examples in the referenced threads.
[edited by: Marcia at 8:50 am (utc) on Nov. 25, 2008]
RewriteCond %{query_STRING} ^name=([^&]*)$
RewriteRule ^modules\.php\?name=News$ [mydomain.com...] [R=301,L]
(old url: [mydomain.com...]
new url: [mydomain.com...]
[edited by: roham at 10:08 am (utc) on Nov. 25, 2008]
RewriteRule ^news.html modules.php?name=News [L]
works fine and with "news.html" request prosses "modules.php?name=News" but the problem is reverse state i mean make url:
[mydomain.com...]
to
[mydomain.com...]
and send 301 stat wont work.
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /web/modules\.php\?name=News\ HTTP/ [NC]
RewriteRule ^modules\.php$ [mydomain.com...] [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /web/modules.php\?name=Forums&file=viewtopic&t=([0-9]*)\ HTTP/ [NC]
RewriteRule ^modules\.php$ [mydomain.com...] [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /web/modules.php\?name=Forums&file=viewtopic&p=([0-9]*)\ HTTP/ [NC]
RewriteRule ^modules\.php$ [mydomain.com...] [R=301,L]
There's no need to examine THE_REQUEST for the query string informationYou could simply look at the QUERY_STRING instead.
...unless there is also an internal rewrite rule that rewrites client requests for the URL example.com/web/news.html to the filepath /modules\.php\?name=News
If this is the case, then examining THE_REQUEST before doing the redirect is required in order to prevent an 'infinite' redirect/rewrite loop. The logic when examining THE_REQUEST is, "If the query-string URL is being requested directly by the HTTP client (browser or robot), rather than as a result of a previously-invoked internal rewrite, then redirect to the search-engine-friendly static-looking URL. Otherwise, do nothing."
Jim