Forum Moderators: phranque
Here's the facts...
- The *actual* web page URL is located at example.com/widgets/z00001.php
- I'm rewriting them to be more friendly example.com/z00001
- All links within the site link to the /z00001 format (so there shouldn't be any links to the *actual* page.
That works which is great.... However I want to disable people from accessing the actual location of example.com/widgets/z00001.php - I only want them to use the friendly URL and have them redirected from the actual file to the redirected URL (while still loading the actual web page behind the scenes).
Make sense?
Here's what I have so far:
RewriteRule ^z([0-9]+)$ widgets/z$1.php [L,NC]
I'm guessing I need another rule but I don't know how to do it. Can this even be done? Help!
Note: I tried this but it didn't work:
RewriteRule ^widgets/z([0-9]+)\.php$ http://www.example.com/z$1 [R=301,NC]
[edited by: Swanny007 at 12:56 am (utc) on Mar. 5, 2008]
There's a long thread from only yesterday with starting code that you'll need.
[webmasterworld.com...]
It redirects all pages from the widgets directory (not just the files that start with z) but that's good enough for me. I don't have an index.php file there either so if the next person looking at this code has an index.php in that folder, they'd need to find a workaround for that.
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /widgets/[^.]+\.php[^\ ]*\ HTTP/
RewriteRule ^widgets/([^.]+)\.php$ http://www.example.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /widgets/[^.]+\.php
RewriteRule ^widgets/([^.]+)\.php$ http://www.example.com/$1 [R=301,L]
Jim
See the regular expressions tutorial cited in our charter [webmasterworld.com] for more information. Then have a go at "adjusting" that code yourself... Post back if you need more help.
Jim