Discussion:
ReWrite specific domain's ALL .html requests to a Python Script
(too old to reply)
n***@gmail.com
2013-01-17 13:29:02 UTC
Permalink
My website is superhost.gr and i also have many other addon domains and their respective folders to the same cPanel.

I use the following directive to rewrite all .html requests to a python script.

--------------------------------------------
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^/?(.+\.html) /cgi-bin/counter.py?htmlpage=$1 [L,PT,QSA]
--------------------------------------------


1. Does the above RewriteRule i'm using apply to the current folder which is placed into or in ALL sub-folders as well?

2. Should i isolate superhost.gr's website content(index.html, data folder, .htaccess , cgi-bin[even this can?)) in it's respective superhost.gr folder or i would still have loading issues?

or perhaps,

i should maintain superhost.gr's website content within /home/nikos/public_html as it is now?
That would also require to alter .htaccess directive to only rewrite .html files pertaining to superhost.gr's specific requests, and NOT affect the other folders as well, which exist for the other addon domains.

Can you please alter the existing .htaccess code to ONLY apply on superhost.gr's specific .html requests? (i don't like the idea of creating separate .htaccess files for every folder to disable the engine off)


What of the above solutions would work best?
Kees Nuyt
2013-01-17 19:12:20 UTC
Permalink
Post by n***@gmail.com
My website is superhost.gr and i also have many other addon domains and their respective folders to the same cPanel.
I use the following directive to rewrite all .html requests to a python script.
--------------------------------------------
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^/?(.+\.html) /cgi-bin/counter.py?htmlpage=$1 [L,PT,QSA]
--------------------------------------------
1. Does the above RewriteRule i'm using apply to the current folder which is placed into or in ALL sub-folders as well?
2. Should i isolate superhost.gr's website content(index.html, data folder, .htaccess , cgi-bin[even this can?)) in it's respective superhost.gr folder or i would still have loading issues?
or perhaps,
i should maintain superhost.gr's website content within /home/nikos/public_html as it is now?
That would also require to alter .htaccess directive to only rewrite .html files pertaining to superhost.gr's specific requests, and NOT affect the other folders as well, which exist for the other addon domains.
Can you please alter the existing .htaccess code to ONLY apply on superhost.gr's specific .html requests? (i don't like the idea of creating separate .htaccess files for every folder to disable the engine off)
What of the above solutions would work best?
I don't have all answers, but perhaps this helps.
The configuration example below works fine for me.
In my case with php, but the same mechanism should apply to any
script language. The php script interprets
$_SERVER['PATH_INFO'] and $_SERVER['QUERY_STRING'] to find out
what has to be done.

Relevant part of the Configuration:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName site1.domain1.tld
ServerAdmin ***@site1.invalid
DocumentRoot "/var/www/html/site1"
ErrorDocument 400 /error/400.html
ErrorDocument 404 /error/404.html

# Any pagerequest is handled by the index.php script,
# for any path in the vhosts' documentroot.

AliasMatch ^/(.*) "/var/www/html/site1/index.php/$1"
<Directory "/var/www/html/site1">
AllowOverride None
Order deny,allow
Deny from all
Allow from all
<FilesMatch "^.*$>
# Always use php
ForceType application/x-httpd-php
</FilesMatch>
</Directory>
</VirtualHost>


# The vhost above does not affect any of the
# "conventional" vhosts below.

<VirtualHost *:80>
ServerName site2.domain2.tld
ServerAdmin ***@site2.invalid
DocumentRoot "/var/www/html/site2"
....
....


HTH
--
Kees Nuyt
Ferrous Cranus
2013-01-18 13:12:26 UTC
Permalink
Actually i find it out my self:

Here it is: rewrite of superhost.gr's specific .html requests.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.superhost\.gr$ [OR]
RewriteCond %{HTTP_HOST} ^superhost\.gr$
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^/?(.+\.html) /cgi-bin/counter.py?htmlpage=$1 [L,PT,QSA]


I just need a way for .htaccess to grab NO ONLY the basename of the html file being requested BUT it's absolute path too.

Please help me ADD it and if you see something wrong the way i has it up until now, perhaps a better way to write this please alter the code too.

Thank you very much.

Loading...