my .htaccess is giving me a Forbidden error - .htaccess

I have the following in the root directory of my site:
RewriteEngine on
RewriteRule ^([^./]{3}[^.]*)$ /index.php?page=$1 [QSA,L]
The .htaccess should be redirecting any request 3 chars or longer without . in the string to the index.php/$string-text as to query my CMS db for output, however when i try and load the index page I get a 403 forbidden error... My .htaccess knowledge is quite basic so try and be easy with me! :)
Thanks
Ric

There does not appear to be anything unexpected with your .htaccess file. If the mod rewrite was not configured correctly, I would expect to see 404 errors or the user being redirected incorrectly. As this does not appear to be the case; you need to widen your search to check that there are no security settings out of place.
I cannot see anything obvious in the httpd.conf file, but here are some of the steps you might want to take.
Remove the .htaccess file - if the website loads okay - then this file is causing an issue somehow; if it doesn't then there is something else wrong.
Check permissions on the web directory being used; there may be a permissions problem.
Check the httpd error log for suggestions.
Ask the question over at serverfault.com or poweruser stack exchange sites.

Ok! So I found the issue, The apache error_log file explained I needed to add this into my .htaccess file and the httpd.conf file -> "Options +FollowSymLinks +SymLinksIfOwnerMatch" and it worked! Now to create my VHost and I am good to go!!! Thanks!!!!!
Thanks
Ric

Related

Can't access files on Magento root

I am looking to install an SSL on my domain name and in order to do so I need to upload a .htm file to the root and access it via the browser, but when I do so, I keep getting a 404 error - this is with any .html page on the root - nothin shows up.
I have edited my htaccess file as well as deleting it all together and still no luck.
The file i'm trying to reach is: http://www.elmershardware.co.uk/xtt5ughh.htm
If someone could help point me in the right direction of fixing this I'd be really appreciative
Thanks
G
I think there is nothing to do with .htaccess. It's something related with your apache conf.
In your apache configuration file check if in DirectoryIndex appears
index.htm as a entry, add it if it doesn't appears and restart apache. Then , try again

Broken links in a Drupal subdomain

Currently I have a site, https://mysite.com/ a working Drupal7 site. I want to have something like this, https://mysite.com/dev in order for me to test the things first on this location before finally uploading it to the main site. What I did was copy the entire folder where all the files located and pasted it inside /dev. I made a duplicate of the DB being used by the main site and edited the file settings.php under sites/default/, edited the base url from https://www.mysite.com/ to https://www.mysite.com/dev. But when I tried navigating the pages using the links(menu, admin) it gives me Page not found response. In addition, I did uncomment this line RewriteBase / on my .htaccess file. I can also log in, but after logging in the links point to the main site like this, https://mysite.com/link1, https://mysite.com/link2 and so on. What did I miss? Can someone please help? Thanks!
I think I finally got it working. I did mention I edited a single line on my .htaccess file which is the RewriteBase / and I did, I promise. I changed it to RewriteBase /dev but when I tested the site, the links still go to the main site as I have mentioned above. What I did was research more on editing .htaccess and somewhere down the road I got here. I lack a few lines of codes which will solve my dilemma, somewhere between RewriteCond and RewriteBase lines. I need to add these lines, RewriteCond %{REQUEST_URI} ^/dev
RewriteRule ^ dev/index.php [L]. After adding these two lines, I tested the site again and it worked like magic. That's it. Thank you guys.

Opencart: SEO URLs not working in the second store

My default store is http://www.mydomain.com/store1
My second store is http://store2.mydomain.com
In the .htaccess file, I have RewriteBase /store1/
In the Admin - Catalog > Information, the About Us page is set to appear in both stores.
This URL works fine: http://www.mydomain.com/store1/about_us
However this URL shows Internal Server Error: http://store2.mydomain.com/about_us
Is it happening because the default store is installed within a folder(/store1/) and not in the root? Is there a way to resolve this issue?
Yes this is caused by the RewriteBase being set. Simply remove the RewriteBase /store1 line from your .htaccess file and that should fix it. Most sites will be able to guess the correct RewriteBase and so it's not necessary. If that doesn't work, you may want to try this solution

htaccess rewrite resulting in 500 Internal Server Error

I am trying to get pretty urls using htaccess for SLIR image resizing plugin.
I want to rewrite something like below:
Before Rewrite:
localhost/img/600x400/slider/image.jpg
After Rewrite
localhost/application/public/slir/index.php?r=slir&w=600&h=400&i=img/slider/image.jpg
But the following code is returning a 500 Internal server error...
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)/([0-9]{1,4})x([0-9]{1,4})/(.*)\.(gif|jpg|jpeg|png) application/public/slir/index.php?r=slir&w=$2&h=$3&i=$1/$4.$5 [NC,NE,QSA,L]
</IfModule>
Please help me.....
UPDATE
I thought it was a File Permissions issue...
so I checked all the related directories and files, surprisingly there were all 755/644.
Then I directly checked the /application/public/slir/index.php. It was not accessible.
I created another file named hello.php in the same slir directory and hello.php was accessible.
Then I moved the SLIR directory to the another folder named public. Here, both the index.php and hello.php were accessible.
After that, I moved SLIR directory to back to the original scripts folder. In scripts folder, hello.php is accessible but index.php is not accessible.
Now, Both files have same permissions and are in same folder.. I dont know what is happening here... :/ :/
Someone please help me......
In case anyone else is looking at this - the problem I found was these two lines in the htaccess file:
php_value auto_prepend_file none
&
php_value auto_append_file none
some servers don't allow them.
moving them to my php.ini file solved it for me:
auto-prepend-file = none
auto-append-file = none
That is probably because you are editing the .htaccess file with a Windows based editor like notepad. Notepad adds some characters to the file which you can't see, but they mess with the .htaccess. I recommend using an editor like Notepad++ and setting the mode to Unix, so it won't mess with the server..
Speaking technically that is because Linux and Windows have different type of EOL ( End Of Line ) so that notepad adds some characters to the end of every line to go to the next line, but Unix won't recognize them, because it has it's own type of EOL..
Slashes are normally forbidden in query strings, but you can enable them by setting
AllowEncodedSlashes directive.
You may also want your rewrite rule to use percent encoding for slashes (that is %2F) so after rewrite:
localhost/application/public/slir/index.php?r=slir&w=600&h=400&i=img%2Fslider%2Fimage.jpg
See also How do you configure apache php to accept slashes in query strings
Duplicate, phrased very differently:
Has anyone used Smart Image Resizer on subdomain sites?
The problem is the subdomain...

url rewrite don't redirect to the correct page

I have the following rule in .htaccess file:
RewriteRule ^cat-([0-9]+)\.html$ ad_list_cat.php?category_no=$1
the ad_list_cat.php file is in a sub folder /contents/. I also tried
RewriteRule ^cat-([0-9]+)\.html$ /contents/ad_list_cat.php?category_no=$1
when I enter the url 'http://localhost/cat-1.html' it gives error 404.
I think the problem with sub-folder.
whats wrong in my rule?
Regards:
Because it is looking for your ad_list_cat.php in your root dir.
Please read a little about re-write rules BEFORE you start asking questions.

Resources