PDA

View Full Version : How to ignore page extention using URL Redirection?


taylormah
07-13-2009, 10:52 PM
I am learning URL redirection. Just for the heck of it, I want to try a rule that will ignore the page extension. For example, if user types either of these, (or any other extension)
domain.com/parrot/page
domain.com/parrot.page.html
domain.com/parrot/page.php
domain.com/parror/page.jsp
domain.com/parrot/page.elephant
domain.com/parrot/page.ferrari

all will be redirected to "domain.com/parrot/page.html". So far, I have written

RewriteEngine on
RewriteRule ^parrot/([a-zA-Z0-9\-\_]+)\.([a-zA-Z0-9\-\_]*)$ parrot/$1.html [NC,L]

I have also tried
RewriteRule ^parrot/(.*)\.(.*)$ parrot/$1.html [NC,L]

But neither is working. Every time I use some extension that doesn't exist in directory, I get 404 error. What could I be doing wrong?

EDIT: I am actually trying this on a server where I have been granted rights to a directory thru FTP so I could play and learn. I am creating the htaccess file within this directory. I notice that every time I dont type a page extension, it still loads, so that tells me that there is already a rewrite rule in place, maybe on the domain's index directory. Could there be something in the domain's root htaccess file that may be hampering with my ability to write desired rewrite rule??

abduraooft
07-14-2009, 10:39 AM
Don't you need to specify the directory in the target part of the rule?

taylormah
07-14-2009, 10:54 PM
Don't you need to specify the directory in the target part of the rule?

Thanks for pointing that out. I have given it a try and its still not working. I have edited my original post to reflect it.

jww_van
09-24-2009, 03:58 AM
http://www.pangosoft.ca provides url redirection solution (high performance, bulk loading, page to page ), especially good for large scale site migration

jww_van
09-24-2009, 03:58 AM
check with them, they must have good way to answer your question