Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I think there is something obvious that I've overlooked, in relation to restricting access to a particular reports.php file, via the RewriteCond directive
Rewriting does occur successfully, without the RewriteCond directive
This is the relevant section in httpd.conf:
Code:
<Directory /var/www/phone/>
AllowOverride None
Options FollowSymlinks
Order Allow,Deny
Allow From all
RewriteEngine On
RewriteBase /phone
RewriteCond %{REQUEST_URI} ^(.*)reports\.php$ # the RewriteRule directive does work without this directive
RewriteCond %{REQUEST_FILENAME} !-f # tried this to stop 'File does not exist' messages ie /var/www/phone/admin, referer: http://www.viewed-domain.com/phone/admin/reports.php, does not exist
RewriteRule ^(.*)$ http://www.source-server-domain:88/$1 [QSA,P]
ProxyPassReverseCookieDomain www.source-server-domain.com:88 www.user-viewed-domain.com
ProxyPassReverseCookiePath / /phone
</Directory>
Your rewrite should work if it's in httpd.conf. Are you sure you've restarted apache and cleared your browser cache before testing?
Please not hat you have:
Quote:
AllowOverride None
With this setting whatever is in a .htaccess will not take effect
Hi
I enabled the rewrite log and discovered there are other required directories, that may not be covered by the directive to limit to:
'/admin/reports.php' and result in matching problems, eg from the rewrite.log
to further restrict accessibility to /phone/admin/reports.php only, but I want to stop direct access to:
/phone/admin/config.php
other than when first accessed via /phone/admin/reports.php
(totally blocking access to the config.php stops access to /phone/admin/reports.php)
Thanks
HTTP_REFERRER would be an elegant solution but I can't get it to work; the RewriteRule, ie
RewriteRule ^phone/admin/config.php - [F]
might be causing problems as .../phone/admin/config.php only exists on the machine the browser is meant to be redirected to
Thanks
HTTP_REFERRER would be an elegant solution but I can't get it to work; the RewriteRule, ie
RewriteRule ^phone/admin/config.php - [F]
might be causing problems as .../phone/admin/config.php only exists on the machine the browser is meant to be redirected to
Compfused
Did you try it?
I guess it should work, as the RewriteCond checks the referer and forbids parsing if it/s not the correct one. If the referer is correct, the rewrite to the backend should happen:
Hi...HTTP_REFERER will not restrict access as advertised. Cannot find any clues in the rewrite logs. Php.ini seems to be properly configured to send http_referer information.
Some promise seems to be in:
Code:
RewriteCond %{REQUEST_URI} ^/phone/admin/(reports|config|images|common) #'images' and 'common' are required dirs
RewriteRule ^(.*)$ http://www.second-domain.com/$1 [QSA,P]
if...there is a way to make 'config' conditional on 'reports' having been prior requested??
Hi...HTTP_REFERER will not restrict access as advertised. Cannot find any clues in the rewrite logs.
...
if...there is a way to make 'config' conditional on 'reports' having been prior requested??
HTTP_REFERER is your way to do what you want.
It should work if the actual referer is the one used in the RewriteCond. Use the following to log what mod_rewrite does:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.