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";
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 have react app running on apache2.
In my app, there are 3 pages: home, about, register
I have 3 route like this:
<Route path="/home" component={....} />
<Route path="/about" component={.....} />
<Route path="/register" component={....} />
So, app works perfectly, when I go to www.onlyexampleurl.com, app is loaded correctly. I can list in home, about, register fine.
But, problem is, when I go directly to www.onlyexampleurl.com/about i am getting 404 from apache, because app is download from root path '/'.
How can I fix it? When I put www.onlyexampleurl.com/about to browser I want load about page from my app, but I am gettint 404 from apache.
Thank you for any help!
You need to redirect all requests to your entry file (assume it's index.html). Put in .htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]
This is standard solution for Single Page Apps.
This is a late response to the question, but I though I'd share what worked.for me, in case anyone bumps into the same problem.
This is assuming Ubuntu OS, I have not been successful for Linux:
I've followed certain steps from this post from Reddit and I can attest this works for making SPAs run in Apache web server with proper routing.
To quote:
1) In the apache2.conf located in etc/apache2/ I turned AllowOverride to All. I also added Servername localhost in the file. (I somehow skipped this last sentence, but still it worked fine in the end)
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
2) In the hosts.debian.tmpl file found in /etc/cloud/templates I added 127.0.0.1 <yourdomain.com> to the file where the other ips of the similiarity are.
127.0.0.1 yourdomain.com
3) I ran sudo a2enmod rewrite. Then I restarted the apache server via service apache2 restart. This turns on mod_rewrite.
Lastly inside of my project folder /var/www/html , along side my index.html file I created a .htaccess file and added in the following:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^.*$ / [L,QSA]
End quote
Assuming you've run npm run build and then copied all the contents inside the build folder to your public directory, this should work.
When I first started web dev, I wasn't really sure I made the VirtualHost config right, so what I usually did was first to make a dummy index.html with, say, Hello World example. When I've confirmed that I'm able to see Hello World in the browser (which means I got the VirtualHost config right), I dump the contents of the build folder to where the dummy index.html was.
Hope this helps you now as much as it did for me!
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 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.
I am facing problems with a site that I am trying to deploy. The site is working fine on my development host, but fails on deployment. Both hosts have a very similar configuration, both are Ubuntu Linux distros (dev: 11.10, deploy: 10.04), both use apache2, etc.
Both sites have mod_dir enabled, but the deployment one seems not to add the trailing slash to directory names, while the development one does. So, when I enter this URL (removed http to avoid silly stackoverflow antispam filtering):
devel.mydomain.com/admin
The development host redirects it to:
devel.mydomain.com/admin/
In deployment http://mydomain.com/admin is not redirected to mydomain.com/admin/ for unknown reasons, and I end with a 404 error. Of course if I enter mydomain.com/admin/, adding the trailing slash by hand, it works as expected. But I rather like to redirect also mydomain.com/admin to mydomain.com/admin/
The question is WHY in devel mod_dir seems to be doing the redirection and in deployment it does not.
I have done a grep within configuration files to see if the DirectorySlash directive was being disabled somewhere and found nothing. It is neither enabled explicitly on devel, so I think it should be on by default. Anyway I add this to my .htaccess file on deployment host:
DirectorySlash on
But it did not work neither.
Any hints?
The /admin folder is password protected. I did not think that this was relevant, but in fact it is.
Also I have these rules on my .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]
</IfModule>
The problem is related to this - see here for a good explanation.
Basically, when Apache generates a 401 error to ask the browser for a password, it also generates another request that does not use any folder, directory, or symlink, so it is redirected to index.php.
The workaround is to add this to the .htaccess file on site root folder:
ErrorDocument 401 /error/null.html
ErrorDocument 403 /error/null.html
and create that file, for example like this:
touch ./error/null.html
These are not best practices but they'll do for now while I look for a better solution.