|My url rewriting is not working.Plz help me|
My url rewriting is not working
| 6:22 am on Oct 16, 2006 (gmt 0)|
my url rewriting is not working while server has mode rewrite module.My .htaccess file is follows.Plz help me this is urgent.Thanx in advance.
Addhandler application/x-httpd-php .shtml .php
RewriteRule ^index\.shtml$ test.shtml
RewriteRule ^abstractors-states-(.*)\.shtml$ /abstractors.shtml?states=%1 [r,nc]
Thanx & Regards:
| 3:56 pm on Oct 16, 2006 (gmt 0)|
Try leaving out the / in your last line so that it reads like this.
RewriteRule ^abstractors-states-(.*)\.shtml$ abstractors.shtml?states=%1 [r,nc]
If you have access to the apache log files, take a look at them and see what the errors are.
| 10:07 pm on Oct 16, 2006 (gmt 0)|
I see that this code has not got a RewriteCond line to it.
Can you explain why and in what circumstances that would be missing, or why you should have one?
| 10:49 pm on Oct 16, 2006 (gmt 0)|
Several problems with this code:
1) The back-reference to a first RewriteRule pattern is $1, not %1. That's the critical problem.
2) Use of the [L] flag is recommeneded unless you know that you don't need it.
3) The final rule need not (and probably should not) be a redirect - use an internal rewrite only.
RewriteRule ^index\.shtml$ /test.shtml [L]
RewriteRule ^abstractors-states-([^.]+)\.shtml$ /abstractors.shtml?states=$1 [NC,L]
If you really do want an external redirect, then the syntax changes, and you should include a canonical substitution URL and sepcify whether you want a Permanent (301) or Temporary (302) redirect:
RewriteRule ^abstractors-states-([^.]+)\.shtml$ [b]http://www.example.com[/b]/abstractors.shtml?states=$1 [NC,[b]R=301[/b],L]
Using an internal rewrite means that the search engines will list abstractor-states.xyz.shtml as the URL, and request the resource from that URL. The server will then provide the content from abstractors.shtml?states=xyz
Using an external 301 permanent redirect means that search engines will list abstractors.shtml?states=xyz as the URL, and fetch the content from there. This is OK, effciency-wise, but you end up with "ugly" and "unfriendly" URLs listed in search results.
Using an external 302 temporary redirect means that the search engines will list abstractor-states.xyz.shtml as the URL, but that both search engines and visitors will attempt to fetch the content from abstractor-states.xyz.shtml, receive the 302 redirect response from the server, and then have to make a second request to abstractors.shtml?states=xyz each and every time that resource is requested. This doubles the number of requests for those resources to your server, and slows down the page load time, since two HTTP transactions are required for each temporarily-redirected page.
I strongly advise using an internal rewrite to cause search engines to show the "static" or "search engine friendly" URL.