Jump to content

Htaccess Redirect


sugan
 Share

Recommended Posts

Hai,I used redirect in my site. It took well in my previous host, but not in the new one...

RewriteEngine onRewriteCond %{REQUEST_URI} ^/testing/(.*).htmlRewriteRule ^(.*).html http://example.com/testing/test.php?name=$1 [L]

The redirection takes place, but the url shows like

It should be as
Why is it not working?Kindly help!Regards,Suganya
Link to comment
Share on other sites

The two regular expressions you have are conflicting with each other. There's no way they'll both match at the same time.The RewrtieCond wants "^/testing/(.*).html" which would match "/testing/something.html", but not "something.html". The second one wants "^(.*).html" which would match "something.html" (relative to the .htaccess folder I think), but not "/testing/something.html". And in order for the rewrite to be executed, it must match both the RewriteCond and RewriteRule regular expressions.Also, when you have "http://" in your rewriting action (the second argument in RewriteRule), mod_rewrite performs a redirect instead of a rewrite. That reminds me - your title says "redirect", but you're talking about "rewrite". The difference between the two is that with rewrite, the user sees the original URL, and with a redirect, the user sees another URL. Well, that's the "user friendly" explanation anyway.Try to remove the RewriteCond, and make the RewriteRule something like:

RewriteRule ^/testing/(.*).html /testing/test.php?name=$1 [L]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...