I'm working on a directory and on some MOD_REWRITES. I have actually deleted the .htaccess file form the site, But there is still something overwriting it.
Is there any PHP Variables that I can use to find out where the over hanging .htaccess file is being loaded from?
There are so many files, that I fear that there may even be more than one.
Cheers guys
Confusing title.
To answer your title question: do print_r($REQUEST) and find a variable you like.
To answer your body question: check each parent directory's .htaccess, until you hit the root.
.htaccess files are processed in the order they're found, so if there's one overriding things for your page, it would be in one or more of the parent directories. There's also the main server httpd.conf files, which are a preferred location for long-standing .htaccess directives, as that's read only once at server startup, and not per-request as .htaccess files are.
You can check the /etc/apache2/... configuration files, but first make sure you deleted and .htaccess is not just hidden (in unix, files starting with . are hidden by default).
Related
I had a little, slightly annoying problem that was an easy fix but I didn't understand why it took place.
I have a several folders in ../wamp/www/- and in one of them I had a file, that I had created, named index.php. When I clicked on the other directories I could browse through the normal list where I saw all the files, but when I opened the folder where the file Index.php was it executed immediately and I never saw what was in the folder. Instead I had to manually change the url to open other files in that directory.
I deleted index.php and half expected it to run some other .php-file in that directory, but didn't.
I'm aware of that there is a index.php-file in the www-directory (the comments in French though), which clearly is part of the WAMP system I downloaded, but having seen tutorials where people use index.php I'd have expected someone to mention this potential problem.
This is not a problem!
This is how web servers work.
To be specific there is a setting in the Apache config that tells Apache the names of files that it should run Automatically if no actual file is specified in the URL
Specifically this line in httpd.conf
DirectoryIndex index.php index.php3 index.html index.htm
It is normal that a web server will run any of these files if it sees them when only the directory is specified on a URL.
And before you consider changing it, dont. Almost everything you will come accross EXPECTS this to be the case.
When I echo out the document root I get this: /etc/httpd/htdocs
however I get the error, when I try to run my website:
No such file or directory in
/vhost/vhost14/i/n/d/domainname.co.uk/www/testme.php
on this line of code
require_once($_SERVER['DOCUMENT_ROOT']."/_cmsscripts/_init.php");
if I replace the $_SERVER with /vhost/vhost14/i/n/d/domainname.co.uk/www/ it all works, but I've got loads of pages and don't really want to have to go around and change the whole site. First time I've had this issue and not sure how to get around it.
Probably the document root is not where your current website in vhost is configured to or follow_symlinks is not enabled.
Anyway, in order to find things below the current file, you may use:
require_once(dirname($_SERVER['PHP_SELF'])."/_cmsscripts/_init.php");
Obviously, the document root can not be changed by .htaccess for security reasons
Background: I downloaded Joomla 3.2 directly from Joomla's website, extracted the contents and uploaded everything to a subfolder within my /public_html via FTP; with the host being domain.com. I access the frontend via www.{my_address}.com/Joomla3. I have .htaccess and php.ini in /public_html and .htaccess in my Joomla3 folder. It should also be noted that my php version is 5.3.13 and that I am using Filezilla for FTP transfers.
Problem: I am having trouble getting past the Pre-Installation Check. Everything under Recommended Settings is green while all the required settings are green...except the red "No" next to "Register Globals Off".
Attempts: From my desperate search through Google, here's what I've found/tried.
*Register_globals is turned off in php.ini by default in PHP5* - Yet the pre-installation check shows otherwise. Perhaps the host keeps it on?
Put register_globals = Off in php.ini - I placed it in /public_html/php.ini; No change. Also, I had to create php.ini myself. Perhaps it could be in the wrong location?
Place php_flag register_globals off in .htaccess - I placed it in /public_html/.htaccess; I receive a 500 Internal Server Error on both www.{my_address}.com and www.{my_address}.com/Joomla3. When I place the line in /public_html/Joomla3/.htaccess, www.{my_address}.com/Joomla3, I receive Error 500 on just www.{my_address}.com/Joomla3.
Go to Software/Services in HostGator Cpanel and click "php.ini QuickConfig" - Though I know it's for a different host, I tried looking for a similar option/tool on Domain.com's control panel (whatever it may be called), but couldn't find one. Perhaps I overlooked it?
*Put php.ini in /public_html/yourserver/administrator/* - Copied the aforementioned php.ini file into /public_html/Joomla3/administrator; No change. I copied the same file into /public_html/Joomla3/installation; I receive Error 500 yet again.
If you are running PHP5, name your initialization file php5.ini - I changed php.ini to php5.ini; No change. I moved php5.ini to /administrator and /installation.
Those are all the attempts I can think of so far. Please let me know how to solve this. I appreciate all the help I can get. I've been working with Joomla 2.5 and I'd like to experience 3.2.
Note: I don't know what's with the formatting mishap in the 1st and 5th points. Please disregard the asterisks that were meant to italicize.
Create php.ini and .htaccess files outside of your document root.
I will assume your document root is /home/yourusername/public_html then do the following:
Create php.ini file outside of the document root: /home/yourusername/php.ini.
Inside your php.ini file turn register_globals OFF:
register_globals = Off
Create .htaccess file outside of the document root: /home/yourusername/.htaccess.
Inside your .htaccess file put:
SetEnv PHPRC /home/yourusername/php.ini
Create a phpinfo.php file inside your document root: /home/yourusername/public_html/phpinfo.php
Inside your phpinfo.php file put this inside php tags: phpinfo();
Visit phpinfo.php and check the Loaded Configuration File - it should point to the new file.
In the end, I submitted a ticket to Domain.com's support staff with the request to turn Register_Globals off. They responded later that night after doing just that. I wish I could provide more details, but they hadn't provided any (even though I asked).
So, problem solved. Thanks anyways to those who provided ideas to try.
All I want to do is be able to see a PHP file from the root without it going through the rewrites (thus our custom CMS).
Here's what I've done:
In my httpd.conf, I've commented out the call to load the mod_rewrite module.
Next, I've removed the .htaccess file from the root as it had the rewrite rules in it.
I've rebooted the server.
I've searched through phpinfo() and there are no "rewrite" strings to be found
The problem is that the server still rewrites and the request passes through our CMS.
I'm using XAMP (PHP 3.3.1, Apache 2.2.14)
What am I missing?
maybe cache problem in your browser? because a similar thing happened to me and deleting the cache solved it.
Leave it to the details... I was trying to access my_file.php on the root. However, the filename was actually my-file.php (dash vs underscore).
The page I was getting was a 404, which went through the CMS. When I access the proper file, the one with the dash, I get what I'm supposed to.
I appologize for the waste of time :)
On my server, a website resides within a directory similar to /domains/domain.com/public_html. I wish to keep the domain at this path, as all the main files are there, but is there any way to source some files from another location in my server, eg. /global/script.js?
In short, I hope to write a mod-rewrite than can source specific files from outside the DocumentRoot, or something very similar, but I cannot work out a solution.
I figure I could manage this by directing all files to a PHP script (css, js, php, images, etc), which will then work out what file is requested, load the files contents and return it with the correct header. I feel this will more than likely slow down all requests because I believe this requires more processes, is this correct?
No need for mod_rewrite: If all files are in the same directory, you can use alias.
Alias /MyMapDir /global/resources
a request to example.com/MyMapDir/script.js will be mapped to /global/resources/script.js
Note that this works in httpd.conf only!