0

Is that possible to hide the .PHP extension and redirect the URL at same time.

example : http://example.com/test need to redirect to http://someothersite.com

 Options +FollowSymlinks
 RewriteEngine on
 RewriteBase /
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME}\.php -f
 RewriteRule ^(.*)$ $1.php
 RewriteRule ^(.*)/test http://someothersite.com

But its not working.

Any idea ?

Thanks

2 Answers 2

1
Options +FollowSymlinks
RewriteEngine On
RewriteBase /

RewriteRule ^test http://someothersite.com [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]

The code above is not tested, but it should give you an idea about it. Use L flag after each set of rules, as it stops processing of the rest of the rules.

Sign up to request clarification or add additional context in comments.

Comments

1

You need just this:

RewriteEngine On
RewriteBase /

RewriteRule ^(.*)$ $1.php [R=301,L]

For cross domain rewriting:

RewriteRule ^test http://someothersite.com [R=301,L]

Allways use L = 301 for permanent redirectings.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.