I'm testing stuff on localhost, and this is my .htaccess file:
RewriteEngine On
RewriteRule ^login/?$ login.php [NC,L]
FallbackResource error.php
in my root directory (/var/www). It just doesn't work. I've already set the "AllowOverride All" in the configuration file: if I put garbage in .htaccess file I get an internal server error (and not a 404), meaning (I think) that the AllowOverride is set properly.
I get "Module rewrite already enabled" if I give "a2enmod rewrite" and, of course, I restarted apache.
Any suggestion? I don't know where to look.
I had the same problem. I found that this error occured only when I tried to access an address with the .php extension. If for example I tried to access test.mydomain.com/home.php, I would get a 404 error. If, however, I tried to access test.mydomain.com/home.html, I had no problem. So I thought it had to do with php interfering with the redirection.
Turns out I had to comment out the following line in my public_html .htaccess file:
#AddHandler application/x-httpd-php5s .php
After that, I could access files in the webroot folder.
Related
I have an issue with my htaccess file but I dont understand where the mistake comes from:
Ex:
I have the following file in my folder
contact.php
I did a basic rewrite like that
RewriteRule ^about/$ contact.php [L]
so now my contact page is accessible from http://localhost/project/about/
the problem is that page is also accessible from
http://localhost/project/contact/
Why is this happening?
How can I disallow that?
Thanks for all your answers!
That is due to enabling of option MultiViews. Option MultiViews is used by Apache's content negotiation module that runs before mod_rewrite and makes Apache server match extensions of files. So /file can be in URL but it will serve /file.php.
To disallow this you can add this line on top of your .htaccess:
Options -MultiViews
I deployed a symfony2 application on godaddy and I got this error: no input file specified. After some research I managed to solve with some changes on .htaccess file:
DirectoryIndex app.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app.php/ [QSA,L]
</IfModule>
this works but only for urls like /mycontroller, I still get errors when using urls like /mycontroller/newaction. what else can I change to manage it working? thanks
Here is a good post how to fix that problem.
When getting started with Symfony2 using Apache and fast-cgi for PHP, you may get the following message come up when trying to open up
the /app_dev.php/demo URL.
No input file specified. This occurs because the url rewrite module isn’t passing along the pathinfo details properly to the fcgi
php. Here’s how you can fix it.
1.) Open the relavent php.ini file
2.) Look for the cgi.fix_pathinfo setting.
3.) You’ll most likely find it set to 0.
4.) Change it so that it reads cgi.fix_pathinfo=1
5.) Save the changes. Restart Apache.
6.) Try loading up /app_dev.php/demo/. It should work now.
http://wilt.isaac.su/articles/symfony2-no-input-file-specified-
I have a video file whose url is modified by .htaccess
RewriteRule ^videos/([0-9]+)/.*$ cms/support/get.file.php?file_id=$1 [QSA,L]
Now when i load the file
http://web01.agmsdallas.com/videos/966/
I end up with redirect loop and the page fails to load. I have checked by .htaccess rule with others and this appears good. The rule works on a different server. Can any one help what could be wrong. Is there some apache directive which is disabled which is causing this error.
It appears the issue been the welcome.conf file of apache which has
<LocationMatch "^/+$">
Options -Indexes
ErrorDocument 403 /error/noindex.html
</LocationMatch>
Once we commented that out, the redirection works just fine.
It's still showing venue link and it doesn't redirect to directory-testing. is there any right way to redirecting in apache, on ubuntu.
RewriteRule ^(.*)/venue $1/directory-testing [R=301,L]
Have you actually enabled rewriting with:
RewriteEngine on
You can also check that your .htaccess file is actually being parsed. You can just put a syntax error in it and see if it returns error 500. If it doesn't, then you need to enable it in the <directory> section of your httpd.conf with:
AllowOverride All
I was trying to setup Lithium Php framework. I followed the documentation for getting started.
I have done this: *"make sure mod_rewrite is enabled, and the AllowOverride directive is set to 'All' on the necessary directories involved. Be sure to restart the server before checking things."*
Rewrite module is enabled. Verified by
apache2ctl -M
I have changed the AllowOverride in /etc/apache2/sites-available/default file.
Now when I go to http://localhost/LithiumTestApp/, the page loads but sans css, js, images etc as the links do not work.
I can't seem to find what I have done wrong.
I'm running Apache2 on Ubuntu 11.10.
Edit: Contents of .htaccess are:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
Part of Lithium Framework itself. I haven't changed anything here.
I'd recommend first checking to see if your rewrite is working properly.
I usually set a rewrite log path in my vhost file (or set it in your httpd.conf or apache2.conf, whichever your OS uses).
RewriteLog "/var/log/apache2/rewrite.log"
RewriteLogLevel 5
Then do:
tail -f /var/log/apache2/rewrite.log
That will allow you to see the log contents while it's happening and refresh the page and see if everything is in order. I also recommend having a look at your Apache error log to see if there are errors in the request.
Also, make sure your resources folder has write permission.