Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess refuses to redirect URLs without file extensions - straight to 404

So I've been tinkering. Apache's .htaccess was redirecting my WWW client just fine (if there is no WWW present, 301 to the same URL with a WWW included), and it was redirecting things with file extensions (i.e. index.html will redirect to index.php). It's only URLs that are without an extension. It refuses to decipher them.

My current file:

RewriteEngine On
RewriteBase /

# Clean URL
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/?$ $1.php [NS,L,R=permanent]

# Force WWW
RewriteCond %{HTTP_HOST} !^www\.thevgc\.net$
RewriteRule ^(.*)/?$ http://www.thevgc.net/$1 [NS,L,R=permanent]

I've been trying to figure this out all night long now. mod_rewrite is enabled, and I had to create a symbolic link to /etc/apache2/mods-enabled/rewrite.conf before actually making the file, which consists of the following:

RewriteEngine On

Thoughts on this dilemma of mine?

like image 572
Cora Avatar asked Dec 17 '25 02:12

Cora


1 Answers

SO! I found the answer to my problem. Looks like if you run the command a2dismod negotiation it magically starts working, or at least, it did in my case. Problem solved, case closed, thread done. The mystery has been solved.

like image 177
Cora Avatar answered Dec 19 '25 19:12

Cora



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!