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.
Related
I know there are a million posts about this, but I have read through a lot of them and made so many changes to get this to work, but I am at a loss. I have setup a redirect rule in my apache2 server web server, but it does not redirect.
My web server root folder structure:
/var/www/example/
|
|----l
|
|---index.php
|---.htaccess
/var/www/example/l/.htaccess content is:
$ cat /var/www/example/l/.htaccess
RewriteEngine On
RewriteRule ^l/([a-zA-Z0-9]{6})$ l/index.php?redirect=$1 [R=302,L]
I have also tried putting it in the root folder /var/www/example/.htaccess
My rewrite rule appears to be working correctly from this site:
https://htaccess.madewithlove.be?share=6cae684f-740d-4add-b711-53cdb5986681
mod_rewrite.so is installed and rewrite_module is loaded.
I ran sudo a2enmod rewrite and it was turned on
APache2.conf:
$ cat /etc/apache2/apache2.conf
<Directory "/var/www/example">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
When ever I go to https://example.com/l/i4Ikn2 I just get a 404 error.
I just want to know if I am missing something or somewhere to look. I checked the apache2 error.log and there are no error in there pertaining to this.
As #mrwhite and #anubhava mentioned in the comments below my OP, I was mixing up the way my .htaccess file was being used.
I removed the sub-directory flags (the l in the pattern) and added the QSA instead of the redirect (R=302).
This was because I was using the .htaccess file in the sub-directory.
The QSA was the correct 'option' for the redirect/rewrite (still unsure of the difference).
Original:
RewriteRule ^l/([a-zA-Z0-9]{6})$ l/index.php?redirect=$1 [R=302,L]
New (working):
RewriteRule ^([a-zA-Z0-9]{6})$ index.php?redirect=$1 [QSA,L]
I used this guide to install mediawiki version 1.27.0. The install went great, and everything is working.
Currently in the url it still has the index.php in the url, like this: http://example.com/index.php/Main_Page
There is documentation here, and here, but there are sections of these instructions that don't make sense to me.
Here's what I'm using:
Ubuntu 14.04
Apache2
mediawiki 1.27.0
My VM is on Amazon AWS
I'll go through the instructions, and list the problems I'm having.
1. In the instructions they assume that your mediawiki install is setup in /w.
Well, mine is installed here /var/www/html/
2. Find the right apache2 files
I have root access so I'm assuming I will be using two files /etc/apache2/apache2.conf for the AllowOverride All, and /etc/apache2/sites-available/000-default.conf to edit anything related to the VirtualHost section.
3. Setting the rewrite rules
In my /etc/apache2/sites-available/000-default.conf file, in the <VirtualHost *:80> section, I added these lines
RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
I understand that this shouldn't work with my setup, because it's using the /wiki, and /w filepaths, and those don't even exist, but I'm not sure what I should put.
4. Change LocalSettings.php
This step also has me confused for the same reason. It says to set $wgScriptPath = "/w";, which is a directory I don't have, and set $wgArticlePath = "/wiki/$1";, which is not only a directory I don't have, but that variable doesn't even exist in the LocalSettings.php file.
I think if I understood the first step, of changing my directory to /w, then I could get the rest, but obviously, I can't change /var/www/html, to /w, without breaking everything. Thanks in advance.
For all who are not running MediaWiki in the default subdirectoy on your HOST (means not like /w/ or /wiki/) configure your .htaccess like:
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^(.*)$ index.php [L]
And add the article path to your LocalSettings.php:
$wgArticlePath = "/$1";
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 url like this
http://example.com/view.php?id=a1b2c3
I want it to look like this
http://example.com/v/a1b2c3
I am trying this
RewriteRule ^v/?$ view.php?id=$1 [NC,L]
But it is not working and I have no idea why
Try this tweak:
RewriteEngine On
RewriteRule ^v/([^/]+)/?$ view.php?id=$1 [NE,L]
This assumes that mod_rewrite is both installed and activated for htaccess files.
If you are not sure, to check if mod_rewrite is installed, look at the list of installed modules in the output of phpinfo();
By default, mod_rewrite is not enabled for htaccess files. If you are managing your own server, open httpd.conf
and make sure that the webroot directory block contains one of these lines: AllowOverride FileInfo or AllowOverride All
I noticed an odd (to me) mod_rewrite thing happening. Fixing it is not important to me so much as figuring out what's going on. Basically, I have an svg file called test.svg in my document root, as well as an index.php. My expectation, based on my .htaccess file is that visiting http://localhost/test.svg would get me the .svg file (and it does), while visiting http://localhost/test/action would be rewritten to index.php/test/action. Instead, the latter is apparently rewritten to test.svg/action, as I receive the message
The requested URL /test.svg/action was not found on this server.
Here is my .htaccess file:
# Turn on URL rewriting
RewriteEngine On
# Protect application and system files from being viewed
# RewriteRule ^(application|modules|system) - [F,L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]
I am using a Apache 2.2.12 on Ubuntu (installed via apt-get). I think my setup is fairly standard, but I'm not sure exactly what directives or config files would be relevant. I am by no means a sysadmin of any kind, I just use this server to test and develop things locally.
As I said, fixing this issue would be trivial, I just am often confounded by mod_rewrite and would like to understand what's going on here.
Apache's HTTP content negotiation feature is automatically translating from "/test" to "/test.svg". See http://httpd.apache.org/docs/2.0/content-negotiation.html#multiviews
You can disable content-negotiation in .htaccess with the directive:
Options -MultiViews
You can get more information about what mod_rewrite is doing by adding these directives to your Apache configuration (they won't work in .htaccess):
RewriteLog /path/to/rewrite.log
RewriteLogLevel 3
The RewriteLogLevel can be any number from 0 (disabled) to 9 (extremely verbose). 3 should give you enough to see what's going on, but don't use that on a production server.