user5235118
user5235118

Reputation:

RewriteRule returning a different result between server side and localhost

What am I doing wrong? Why will the following open the file test.php which is in my main dir correctly on the server side but not on my localhost?

RewriteEngine On
RewriteRule ^(contact)$ /test\.php?view=$1 [QSA,L]

As result on the server side I get the following page displayed: example.com/contact On localhost, this is opening a kind of Wamp server tree, since I'm using Wamp. Other redirections are working well e.g.

RewriteRule ^index\.html$ /index\.php [QSA,L]

Does someone know what is causing this to happen?

Upvotes: 1

Views: 84

Answers (1)

anubhava
anubhava

Reputation: 784898

Change your rule to this:

 RewriteRule ^(contact)/?$ test.php?view=$1 [QSA,L,NC]

and retest.

This will rewrite contact to test.php in same directory where your .htaccess is kept. Your rule is rewriting same request to test.php on site root due to leading / in target URI.

/?$ on pattern makes trailing slash optional in request URI.

Upvotes: 0

Related Questions