user3552798
user3552798

Reputation: 13

redirect to new page but keep same url

I'm trying to achieve the following

http://domain.com/products/code.php ---> http://domain.com/products/name.php However, I want the url in the address bar to remain http://domain.com/products/code.php despite showing the page http://domain.com/products/name.php.

I have tried to play around with this but it didn't give me the expected result:

Options +FollowSymlinks -MultiViews

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} !^/products/code.php
RewriteRule (.*) /products/name.php [L]

I would love some help, thanks :)

UPDATE: /Sorry, forgot to mention /code and /name are files not directories.

Upvotes: 1

Views: 895

Answers (1)

Howli
Howli

Reputation: 12469

Try replacing

RewriteCond %{REQUEST_URI} !^/products/code/
RewriteRule (.*) /products/name/$1 [L]

with:

RewriteRule ^products/code/(.*)$ /products/name/$1 [L]

EDIT:

RewriteRule ^products/code.php$ /products/name.php [L]

Upvotes: 1

Related Questions