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??
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??