Jump to content
Sign in to follow this  
sugan

Htaccess Redirect

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

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

Hai,I tried yours but it did not work..As i told before, I tested with another server it worked...How to solve it? Is there any other option i can do?Regards,Suganya

Share this post


Link to post
Share on other sites

O..k... try it with your rule and condition, but remove the "http://" in the rewrite action, i.e. leave that part as in my rule.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...