Snow Leopard + mod_rewrite = 403 Forbidden - apache

I am facing a very odd issue with Snow Leopard and Apache's mod_rewrite. I have set this up on Linux servers countless times, and it always worked. Being quite new to OS X, I'm quite puzzled.
This is my current configuration file as found in /etc/httpd/users/username.conf:
DocumentRoot "/Users/username/Sites/"
<Directory "/Users/username/Sites/">
Options Indexes MultiViews +FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Now my problem is that whenever I try to access a rewritten url I get a 403 Forbidden page. I have tried to see if there was any information in the log, but nothing is coming up, so I'm left here wondering. To be sure, my permissions seem to be fine (I have tried 755 and 775).
For reference, this is my .htaccess file:
RewriteEngine On
RewriteRule ^hello$ home.php [NC,L]
RewriteRule ^oops$ sorry.html [NC,L]
Just to make double sure I have set AllowOverride All in the main httpd.conf file (under Directory /).
Any advice is greatly welcome.
Thanks for your time :)
EDIT: I have just noticed that if I use a VirtualHost everything works as expected, so I wonder how my RewriteRules are being read by Apache...

Related

URL Rewriting issue (Apache2 / Debian 10)

I got a basic problem that I can't resolve.
I set up a LAMP server on a Debian 10 machine which run into a Docker container.
PHP and the services Apache and MySQL are functionnal, but I got a problem with the URL rewriting.
It don't run, even on the basic entry point of my web server which is : "http://localhost/"
If I use the real adress, It work, but if I brink a "virtual" adress like "http://localhost/toto" for exemple, I got a 404 error from Apache.
Here is the content of my .htaccess file that I put on the root of my base directory "/var/www/html" :
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !/index.php$
RewriteCond %{REQUEST_URI} !(.css|.js|.jpg|.jpeg|.png|.svg|.ttf|.woff|.woff2|.pdf|.zip|.mp4|.avi|.ogg)$
RewriteRule .* /index.php
In the configuration file of my default website (/etc/apache2/sites-available/000-default.conf), I've the directive "DocumentRoot /var/www/html".
If I do a phpinfo(), I see the "mod_rewrite" in the loaded_module.
Is anybody know how can I solve it ?
Mickaël
Finally..., It's OK !
My .htacess file was just ignored by Apache, because the AllowOverride statement was set to "None" by default in my "apache2.conf".
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
I changed it by "AllowOverride All", I restarded Apache and I could valid that the rewriting work fine.

.htaccess not working on SSL apache

Trying to fix this .htaccess, so it can work on a SSL apache server. Before it was hosted on another Linux server (http://) and was working without problems, but when uploading the files to another Linux server with apache and SSL (https://), it stopped working. The main function is to hide the .php extension...
Here´s what I was using:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f [NC]
RewriteRule ^ %{REQUEST_URI}.php [L]
Thanks for your help!
So, .htaccess files may not be allowed, and by default on many systems they are not allowed. To see if .htaccess is allowed, make this your .htaccess:
BREAK IT!
That should be the only contents in your .htaccess. Attempt to load any page on your website, and if .htaccess usage is enabled, you would see "Internal Server Error" or possibly some other error, but you would not see your actual page.
If you do see the error, that's actually good and means .htaccess usage is enabled. If you don't see the error, it's likely that you will have to find your Apache .conf file and inside look for the line(s):
AllowOverride None
Change that to:
AllowOverride All
If after doing that you still can't use .htaccess, then there may be other apache related files that have "AllowOverride None". On that comes to mind is your virtual host file, and on my system that is located at /etc/apache2/sites-available/.
If you still have problems, check this out:
https://docs.bolt.cm/3.3/howto/making-sure-htaccess-works
Solution is for the issue, need to change in apache2.conf file after that it will works,
Change this file /etc/apache2/apache2.conf
update it same
OLD:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
New Updated Code:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
I had a similar problem. Apache 2.4.23 with .htaccess error 404 set up.
Using it with HTTP works fine; access it with HTTPS didn't work.
I seted AllowOverride All in the http.conf and error 404 wors well.

All URLs redirect to mod_rewrite error page

I have a few platforms (domain.com/omeka, domain.com/wordpress, domain.com/omeka-s) living alongside each other on an Azure cloud server running Ubuntu 14.04.4 and Apache 2.4. A few days ago, I tried installing an additional platform, but doing so seemed to break everything else on the server, so I removed it and reinstalled Apache. After editing the .htaccess file to remove a typo, everything worked. I left for the weekend, came back to work this morning, and everything is broken again.
By broken, I mean every URL on the server redirects to a mod_rewrite installation error page for Omeka (domain.com/install). Omeka has already been installed and running for months. MR needs to be enabled for Omeka to be installed and function properly. MR is definitely enabled.
$ sudo a2enmod rewrite
Module rewrite already enabled
I'm assuming this is a problem with either the /var/www/.htaccess file or the /etc/apache2/apache2.conf file. Here's the relevant .htaccess code that is default for Omeka:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule !\.php$ - [C]
RewriteRule .* - [L]
RewriteRule ^install/.*$ install/install.php [L]
RewriteRule ^admin/.*$ admin/index.php [L]
RewriteRule .* index.php
And here's the relevant(?) apache2.conf code:
<Directory />
Options FollowSymLinks
AllowOverride All
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
AccessFileName .htaccess
If I remove the .htaccess file, or if I just remove some of RewriteRules, everything on the server is inaccessible (including Wordpress & Omeka-S). I'm clearly missing something. Any ideas?
Figured out the problem. Very simple, stupid stuff.
Problem 1: When I reinstalled Apache, the /etc/apache2/sites-available/000-default.conf file reverted the DocumentRoot to /var/www, when it was supposed to be /var/www/html.
Problem 2: There was an additional and nearly identical .htaccess file in /var/www/html/omeka that had a typo. It was missing the ^ before install/.*$
Also, the IT department who set up the cloud server for me installed 2 instances of Omeka (who knows why), one under /var/www and one under /var/www/html, so this whole problem most likely would have been averted (or at least easier to solve) if that wasn't the case.

wordpress permalink postname 404 on localhost

I am facing a very common issue here hoping someone have the same experience could help me.
The issue is quite normal. I could find plenty issue posts and solutions by search google.
For example:
http://wordpress.org/support/topic/wordpress-permalink-404-issue
But the weird thing is after I delete # from
#LoadModule rewrite_module modules/mod_rewrite.so
and also did this part:
I opened up the httpd.conf file and found:
<Directory />
Options FollowSymLinks
AllowOverride none
Order deny,allow
Deny from all
</Directory>
and changed the AllowOverride none to AllowOverride all.
Now it's looking like this:
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
but it's still not working.
I'm using WAMP for my localhost and the website works well when I change permalink setting back to default (with post ID).
Here is the .htaccess code I'm using.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /dev/mysite/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /dev/mysite/index.php [L]
</IfModule>
# END WordPress
Did I miss something? Really need your help! Thanks in advance.
I Got Answer. It's easy only.
1) Go to WAMP logo in right-bottom of Task-bar of Windows.
2) Click left button
3) then Apache -> Apache Modules
4) Tic(select) the rewrite_module
5) that's all.
For More
1) Go to WAMP logo in right-bottom of Task-bar of Windows.
2) Click left button
3) then Apache -> Apache Modules
4) Tic(select) the rewrite_module
5) that's all.
THIS WORKS, THANKS A MILLION.
I spent hours trying to solve this problem, f* ridiculous!
I'm just learning to use wordpress and got completely stuck with a simple thing like adding a page, complete waste of time. Almost decided to use joomla....

Mod_rewrite headache

Alright, I'm just trying to setup a simple rewrite rule for a site.
First off, in httpd.conf I have
LoadModule rewrite_module modules/mod_rewrite.so
Then in a seperate file I have this alias setup
Alias /vworker/ "f:/vWorker/"
<Directory "f:/vWorker/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
Alright now, so the directory of the site is
f:/vWorker/urlmask
In there I have an .htaccess file that says this
RewriteEngine on
RewriteRule ^redirect/([0-9]+)/?$ index.php?redirect=$1 [L]
Now, what I want, is if I go to the url http://localhost/vworker/urlmask/redirect/3161513 it will actually call http://localhost/vworker/urlmask/index.php?redirect?3161513
From my point of view everything seems to be set up right, and if I put gibberish in my .htaccess file I get a server error, so I know it's reading it.
What I end up with is a page that says "Not Found. The requested URL /vworker/urlmask/redirect/94173336828903446 was not found on this server."
Any ideas what I'm doing wrong?
In general, whenever you've got an Alias, you're going to need a RewriteBase to make things work as expected.
In your case, you should have
RewriteBase /vworker/urlmask/
in the same .htaccess as your rules.