Strange issue with .htaccess file unable to remove PHP extensions - php

I am on a VPS running Ubuntu 14.04 x64, and I have enabled mod_rewrite.
This works (i.e. correctly redirects to testfile.php):
RewriteRule ^othername$ testfile.php
But this doesn't (gives me a 404 error, saying "The requested URL /testfile was not found on this server"):
RewriteRule ^testfile$ testfile.php
So I essentially cannot redirect a URL to a file of the same name but with a PHP extension. The two examples are both working locally with MAMP.
What could be causing this issue?

As anubhava said, you just have to add Options -MultiViews at the top of your .htaccess.

Related

Using Codeigniter application on freeBSD system

I have freeBSD installed on IBM server. There is also apache, php and mysql installed on the server. A PHP application running on this machine is working just fine, but our new version of the same application developed in Codeigniter gives a "Page Not Found" error.
The thing is the application is accessible and runs well (only the non-english character are displayed not well) if the index.php is included in the url.
I have modified the file .htaccess to remove the index.php from the url, I kind of need to use the .htaccess in the application's root directory. This (using .htaccess) is actually causing the error.
Please let me know what configuration do I need to do.
Edit:
Bellow is the content of .htaccess in the root directory of the application:
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ /football/index.php/$1 [L]

.htaccess URL Rewrite Error - The requested URL was not found on this server

I have a very simple rewrite rule. My entire .htaccess file is as follows:
RewriteEngine On
RewriteRule ^login/([a-zA-Z0-9-/]+)$ company-page.php?company_url=$1
RewriteRule ^login/([a-zA-Z0-9-/]+)/$ company-page.php?company_url=$1
This is perfectly run on locally Wamp server but not working on online server. It display following error.!
The requested URL /EZsample/login/mereco-technologies/ was not found on this server.
Can anyone help me!
if you are using a VPS please use this article,
1.Make sure u have enabled Mod_Rewrite ?
2.Made the changes in the virtual host configurations
https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_rewrite
This line of code helped me solve a very similar issue:
Options -MultiViews

mod_rewrite not working - results in 404 error and no logs

I’m running localhost XAMPP on my Mac and trying to setup the Apache server with mod_rewrite, here’s my code in .htaccess (which is in htdocs)
<IfModule mod_rewrite.c>
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^test/?$ api/rest/v1.0/api_controller.php?request=$1 [NOCASE,LAST] # Handle requests for “test"
RewriteLog "logs/rewritelog"
RewriteLogLevel 7
</IfModule>
This is the only code in the .htaccess file too.
When I try my link http://localhost/test/1 in my browser, I just get directed to a 404 error.
I’ve checked under htdocs/logs/rewritelog but there aren’t any files nor even a folder called logs.
UPDATE
I’m running Apache version 2.4.10
So it turns out the .htaccess file was saved as .htaccess.txt where the .txt extension was hidden. If you get the same error, check the file in Get Info.

Mod_rewrite enabled but not working - ubuntu (file does not exist)

Im having a problem setting up mod_rewrite. Im using localhost and is on ubuntu.
I already enabled mod_rewrite and also changed the AllowOverride from None to All.
My .htaccess is as simple as this.. since it's not working I wanted to know if it's still not working in its simplest form:
RewriteEngine on
RewriteRule ^sample.html$ sample1.html
When i write sample.html in browser it says "not found"

500 Internal Server Error with Wamp server

I've created a web service using php, slim and mysql but when I try to access the urls it gives me "The server encountered an internal error or misconfiguration and was unable to complete your request."
When I check the log it gives me :
C:/wamp/www/task_manager/.htaccess: Invalid command '.htaccess', perhaps misspelled or defined by a module not included in the server configuration
I checked few things online and I can ensure you that rewrite_module is installed and activated (not commented in the http.config
does anyone know how to fix that?
I ll attach the content of my .htaccess
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ %{ENV:BASE}index.php [QSA,L]
Remove the line .htaccess from your .htaccess file.
if you install new wamp on your system,
and you are using htaccess in your project to rewrite some urls first you need:
Click on wamp icon and Go to "Apache" Then Click on "Apache Modules"
and make sure your RE WRITE extension should be checked.

Categories