Click here to Skip to main content
15,905,144 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a url: www.mywebsite.com/products/game.php

I would like this url to work too on www.mywebsite.com/p/1

I tried :

RewriteRule ^http://www.mywebsite.com/p/1/ http://www.mywebsite.com/products/game.php [L,R=301]


Dows not work...
How to do it on .htaccess?
Posted
Updated 5-Aug-13 7:45am
v2

1 solution

There are quite a few options, so feel free to take whichever one works for your particular setup.

If you want to use /p/1 in links, text, whatever -- and have it rewrite to /products/game.php (using it as a URL shortener):
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^p/1/?$ http://www.mywebsite.com/products/game.php [R=301,L]


If you want /p/1 to display the contents of /products/game.php but still use the shorter URL in the address bar:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/p/1/?$ [NC]
RewriteRule .* /products/game.php [QSA, L]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900