I have a virtual private server that was borked over the weekend, and has been upgraded. Sometime between now and then, some changes have been made that have impacted a mod_rewrite call, but I'm not sure which.
In any event, I have a folder with a PHP script that emulates a CAS server. The system used to work fine and dandy until today. Now, instead of the mod_rewrite directives providing commands via rewrite to the index.php file, Apache goes '404' and sends me up a directory to Wordpress's 404 handler.
This is the htaccess code that used to work:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteEngine On
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?mode=$1 [QSA, L]
The URL variables appeared in CAS-appropriate commands (like cas/login, cas/logout), but are now generating 404s.
There may have been Apache tweaking; do I need to add any commands to the htaccess (like Options Indexes) or something to make Apache listen to the rewrite commands?
Oddly, the force-https command seems to work.
Related
We have recently moved a Magento multi site environment to a new dedicated server, however all the sites apart from the admin URL site (not used apart from admin are) are reporting Magento style 404 pages on the front end.
We have ensured mod_rewrite is turned on, checked the database and manually amended the URLs in PHPMyAdmin to assign some temporary test URLs. The URL assigned to the admin area works fine, and the rest resolve to the server, however every front end is still 404. We have tried adding in index.php to the URL, no change. Checked all file and folder permissions, all OK. Cleared all cache manually and reindexed from command line. No change.
We have checked HTACCESS is correct which it looks to be. We have even taken another backup of the database and full site and restored to another server with the same issues.
We have also tried disabling SEO urls/URL Rewrites without change too.
Error logs dont say a lot either which isnt helpful.
Really struggling with this now so any help or pointers greatly appreciated. Thanks
First Solution:
Replace current .htaccess file with the default .htaccess file from Magento.
Second Solution:
#fastcgi_param MAGE_RUN_CODE default;
If doesn't work, try following solution:
Third Solution:
Is this installed on an Apache webserver? If not, the .htaccess functions will need to be translated to your flavor of web server software.
Has DSO module for mod_rewrite been installed in Apache and been enabled to load?
Is AllowOverrides enabled for the virtual server so Options +FollowSymLinks will function? You may have to check with your hosting service provider and have it enabled.
Is Magento's .htaccess file available in the doc root folder?
Has the rewrite engine been turned on in the .htaccess file?
Has the proper RewriteBase been assigned in the .htaccess file?
General entries in Magento's .htaccess that must function so rewrites will function to eliminate the need for index.php to appear in the URL.
<IfModule mod_rewrite.c>
############################################
## enable rewrites
Options +FollowSymLinks
RewriteEngine on
############################################
## you can put here your magento root folder
## path relative to web root
#RewriteBase /magento/
############################################
## workaround for HTTP authorization
## in CGI environment
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
############################################
## always send 404 on missing files in these folders
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
############################################
## never rewrite for existing files, directories and links
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
############################################
## rewrite everything else to index.php
RewriteRule .* index.php [L]
</IfModule>
Third solution from Fiasco Labs
I've trying out url rewriting with a php script on my xampp server. First i created a .htaccess on the same folder as the script and then wrote the following lines in it
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^direct/?$ direct_name_here.php [NC,L]
to rewrite localhost/map/direct_here123.php to localhost/map/direct/
But the browser displays the url localhost/map/direct_here123.php instead of localhost/map/direct/
How can i fix it?
regards
ED
I have installed MAMP on my laptop and moved my web project (developed using CodeIgniter) under MAMP's webroot.
I use an .htaccess file to hide my index.php file within my urls and everything is working fine...almost, everything.
I'm able to surf my site locally as in my remote server but some folders/files are not recognized. Looks like they are missing or the path is not matching the physical location on my laptop.
Basically I have configuration like below:
MAMP
htdocs
myFolderSite
.htaccess
site
myApplicationFolder
.htaccess
config
controllers
views
.....
...
myPublicFolder
css
images
.....
...
Surfing my site locally css and images are not visible. All the required files are present under the proper folders within myPublicFolder.
The .htaccess file I'm using in myFolderSite appears as below
RewriteEngine On
RewriteBase /myFolderSite/
RewriteCond $1 !^(index\.php|images|upload|users|thumb|fckeditor|public|css|js|robots\.txt|sitemap2\.xml)
RewriteRule . index.php [L]
Am I missing something?
Thanks in advance
The CodeIgniter wiki has a good article on Mod Rewrite that is worth looking at. Specifically, these two lines will stop actual files and directories being redirected.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
I've used this across a few different servers and Macs, without too many problems, so hopefully it helps.
Im using a J2ee application with spring framework 2.0 on a apache tomcat 5.5. I have used URL mapping to change the extension from .jsp to .htm. I have an URL which looks like this
http://www.800promotion.com/promotion.htm?cid=1344159422528120632840257756098788
I want to change it to
http://www.800promotion.com/1344159422528120632840257756098788
I have referred samples of working on mod_rewrite. However I cant seem to get it working. These are the lines in my .htaccess file.
RewriteEngine on
RewriteRule ^([^/.]+)/?$ /promotion.htm?cid=$1 [L]
I have checked with my host and they said mod_rewrite was supported on the server. I do not have access to the httpd.conf file. However I have verified from the support that AllowOverride is set to all. When I hit the URL the page works fine however the URL doesnt get mapped. Where am I going wrong?
RewriteEngine On
RewriteRule ^(.+)$ promotion.htm?cid=$1 [QSA,L]
Try this
You need a correct .htaccess directives. Try the following solution:
RewriteEngine on
RewriteBase /
RewriteRule (.*) promotion.htm?cid=$1 [L,I,U]
I started working on a project in the mid. We are using Zend Framework, PHP, MySql, Ajax, jQuery and jSon on Ubuntu. It was working on ubuntu.
Now I switched to Windows. I installed Wamp, Eclipse and create a host(test.dev) on windows for my project. But when start the project by test.dev. it give me the following error on browser windows:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, admin#localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
then i deleted the public/.htaccess file and try again. This time no error is displayed but browser page is blank. I checked the firebug(mozilla browser) and there is no response in consol.
My .htaccess file is like that:
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
Can someone tell me that what problem may be and how to solve this. If you need some other information then tell me what type of information required for you to solve this.
Thanks
A 500 - Internal Server Error is often caused by something incorrect in a configuration file.
Considering it works (i.e. no error) when you delete the .htaccess file, there's probably something in it that causes troubles.
As a first idea (as there is not much in yours, except rewrite rules), are you sure that mod_rewrite is enabled ?
You can check this in your Apache configuration : there should be a line like this one :
LoadModule rewrite_module modules/mod_rewrite.so
If this doesn't help, do you have any error message in Apache's error_log file ?
The .htaccess file looks fine. My bet is the mod_rewrite module is not activated in your local Apache. Check out your httpd.conf file..
Take a look into Apache's error.log file first. It will give you detailed information about the 500 error and its cause.
What Pekka and Pascal said is right, but you can take a look to if mod_env module is loaded in your Apache configuration so you can use the SetEnv directive.
I have this same problem when I put an application in production. To my surprise, this module is not enabled in some installations.