Using rewrite rules across multiple virtual hosts

Using a single web hosting account to host multiple sites

Postby richardk » Wed Dec 24, 2008 9:05 am

If someone visit /file.php or /file.asp or /file.htm or /file.jsp, they should be redirected to /file/

If the files exist, replace
Code: Select all
# Remove the .php from PHP files (only files
# that exist).
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{DOCUMENT_ROOT}%{SCRIPT_FILENAME} -f
RewriteRule ^(/.+)\.php$ $1/ [R=301,L]

with
Code: Select all
# Remove the .extension from PHP, ASP, HTML
# and JSP files (only files that exist).
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{DOCUMENT_ROOT}%{SCRIPT_FILENAME} -f
RewriteRule ^(/.+)\.(asp|html?|jsp|php)$ $1/ [R=301,L]


Or if they don't exist add
Code: Select all
RewriteRule ^(/.+)\.(asp|html?|js)$ $1/ [R=301,L]

after
Code: Select all
RewriteRule ^([^\?]*)index\.php(\?.*)?$ $1$2 [R=301,L]


/htmlfile to go to /htmlfile.html and /aspfile to go to /aspfile.asp, etc.

This can be done by the way.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby AbuAaminah » Wed Dec 24, 2008 9:29 am

Works perfectly.

A
BIG THANKS
For all of you're help.
AbuAaminah
 
Posts: 40
Joined: Mon Dec 08, 2008 6:31 pm

Postby AbuAaminah » Wed Dec 24, 2008 10:29 am

One question... Is it possible to put something in a directory's htaccess to disinherit all of these rules within that directory and its child directories?
AbuAaminah
 
Posts: 40
Joined: Mon Dec 08, 2008 6:31 pm

Postby richardk » Wed Dec 24, 2008 1:38 pm

Try
Code: Select all
RewriteEngine Off
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Previous

Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 28 guests

cron