Forum Moderators: phranque

Message Too Old, No Replies

Apache rewrite rule

         

itsdone

2:09 pm on Jul 28, 2009 (gmt 0)

10+ Year Member



I have the following rules
RewriteCond %{HTTP_HOST} ^abc.com$ [NC]
RewriteRule ^(.*)$ _http://www.abc.com$1/ [L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html
Rewriterule ^index\.html$_ [abc.com...] [R=301,L]
already
and i need one more rules so that
abc.com/<anything> redirects back to abc.com
somehow I m going in loops with any of the rules I tried.

Thanks.

jdMorgan

4:09 pm on Jul 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Actually, you could easily modify the second rule to do that, but it would be "search engine suicide."

Please explain what you are trying to accomplish by redirecting *all* to "/". Be aware that this means that all requests for images, css files, external JavaScript files, robots.txt, SiteMap.xml, etc. will all be redirected to the same URL. In most cases, that would be a very, very bad idea.

[added]
Also note that with your existing code, your two rules are in the wrong order -- Put the most specific external redirect rules first, followed by the least-specific, then the most-specific internal rewrite rules, again in order from most to least specific.

This avoids problems with multiple redirects (e.g. on a "doubly-wrong" request for example.com/index.html), and avoids having your external redirects expose internally-rewritten filepaths as URLs to the client.
[/added]

Jim

itsdone

6:29 am on Jul 30, 2009 (gmt 0)

10+ Year Member



Hi Jim

I needed this for testing.it wont be exposed to search engine.

This is what solved my problem

RewriteRule ^(.*)$ [abc.com...]

Thanks for your comments :)

jdMorgan

2:52 pm on Jul 30, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You should add a trailing slash to your substitution URL, and specify either [R=301,L] or [R=302,L], as appropriate to your needs.

Jim

itsdone

6:23 am on Jul 31, 2009 (gmt 0)

10+ Year Member



Ok,I will do that.Thanks Jim :