I have created a new C9 AWS instance, and my .htaccess file is being ignored.
Here are the file contents:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
Here is what I have done:
I have changed my httpd.conf to Allow All.
I have restarted the server after making changes to httpd.conf file
I have tried putting garbage in the .htaccess file to test it
I have changed the default directory to match what runs in c9
Here is a picture of my httpd.conf:
Any help with this would greatly be appreciated!
Please check as you need to change the file from following location as a root user:
sudo nano /etc/httpd/conf/httpd.conf
I ended up doing two things to fix this issue:
Changing the listening port in the httpd.conf to 8080
Chmod all directories to 755 find /home/ec2-user/ -type d -exec chmod 755 {} +
Related
I want to prevent uploading files to a specific directory,
as I already have some php and html files in this directory.
I was trying .htacess:
Options -Indexes
<Files *>
deny from all
</Files>
This is working, but makes me unable to open any files from the folder.
I then tried with this:
<Files *.php>
deny from all
</Files>
But then I cannot start index.php in this folder...
Can anyone help me?
If you're on Linux, use the chmod command to disable uploads, but still leave browsing enabled.
Use it like this: chmod 755 directory_path or chmod 555 directory_path. You may need to become root in order to make these changes, depending on your setup.
The first chmod command in this example allows only the directory owner to upload files, others can only read the directory contents. The second chmod command doesn't allow anyone to write to this directory. For more information, use man chmod inside your shell.
I have a directory called "files" that contains an .htaccess file with the following rule:
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ /assets/secure.php?f=$1 [NC,L]
So when a user tries to view any file within the files directory they are redirected to /assets/secure.php file. This file is meant to check permission on the user but to simplify it all it does now is prints the file name that the user tried to access.
secure.php code
$f = $_GET['f'];
echo 'file Name: '.$f;
The "files" directory contains other directories with chmod permissions of 770. Now if i try and view a file in one of these 770 directories I get a 404 file not found. I've I make it world executable then it echos out the file name as expected.
This set up was working fine on another set up so guessing it's down to ownership or something. But they all seem to have same group and owner.
The server is apache with cpanel installed.
Any ideas?
I installed Magento at the root of my domain and I'm trying to install a forum to the sub folder at mydomain.com/forum/ but it seems the .htaccess of Magento (located at mydomain.com/.htaccess of course) is preventing any requests to the sub-directory /forum/.
Whenever I access /forum/ or /anything it just gives 404 error instead of serving the actual files located there.
Any idea I can fix this without breaking the URL rewriting for Magento? It's very annoying....
Thank you!
Problem solved.
Seems it's a permission issue because I had suPHP installed. While I did chmod everything under /forums/ to be 644 for files and 755 for folders, I didn't do so for /forums/ itself.
chown -R youruser /home/youruser/public_html/forums
chgrp -R youruser /home/youruser/public_html/forums
find /home/youruser/public_html/forums -type f -exec chmod 644 {} \;
find /home/youruser/public_html/forums -type d -exec chmod 755 {} \;
suPHP: http://www.kavoir.com/2012/10/500-internet-server-error-for-incorrect-permissions-after-installing-suphp-and-uploading-php-script.html
After chmod /forums/ itself to be 755, mydomain.com/forums/ is correctly accessible without any errors.
I don't seem to have this problem with my magento install. Try creating a test folder in docroot and put an index.php file in there. Then navigate to mydomain.com/test/ and you should see the contents of your index.php. Also check that your magento .htaccess file has these lines:
## never rewrite for existing files, directories and links
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
Perhaps your forum has its own .htaccess that is causing 404s? Your forum may need to specify
RewriteBase /forum/
is it possible to mirror directory with htaccess?
For example:
/folder1 <= is empty
/folder2/blah/blah <= here is content
I want folder1 to display folder2 contents. So that when you go to folder1/ you can navigate to folder1/blah/blah/files
is this possible?
Alias can do this, although folder1 shouldn't exist for it to work:
Alias /folder1 /folder2/blah/blah
In .htaccess files, you can only Alias to a directory inside the web root.
It doesn't always work in .htaccess files, depending on the server configuration.
In the central configuration, you may have to use an absolute path as the Alias target.
I just copied my magento site over to a local server running CentOS 5.4. The browser said it can't locate the location of the stylesheets. The stylesheets are within /skin/frontend/my_new_interface/design2/css. I tried to view in the browser and I can't view any of the files within the css directory. I verified a million times that I'm typing in the correct location. I can view files within /skin/frontend/my_new_interface/design2. Can't browse directories within browser however.
I typed in ls -l css
and get:
-rwxr-xr-x 1 apache apache
listed for all the files
I tried chmod -R 755 and the directories
I changed the apache conf Options Indexes
But still when I browse the directories I get Forbidden. However, in another fresh installation of magento in the same www dir, I am able to browse directories. As far as I can tell both installations have same ownership and permissions.
I also tried
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
which was recommended in the magento wiki
I've just run out of ideas.
You'll need to add Options +Indexes to your httpd.conf or in a .htaccess file in the css/ folder to view the folder contents through the browser. This is bad ju-ju though. Do you really need to switch this on, or can you keep doing it through the ssh session?
On the CSS file note, can you type pwd when in the CSS directory? That'll help us confirm you've got the correct location. Do you get "Forbidden" when you try to view the CSS file directory, or just when you try to view the directory contents?
The file permission were set up correctly. I figured out that the .htaccess had a rewrite rule set for the css directory that was causing the problem. I inherited this site and am still not aware of all the little modifications done throughout.