I am using a basic hosting plan on Host Gator. I installed MediaWiki and I am getting URLs with index.php?title= in it, i.e. www.domain.com/index.php?title=Main_Page
I want to remove the index.php?title= part and just have the title of the page appear. I am following the instructions from http://www.mediawiki.org/wiki/Manual:Short_URL/Page_title_--_Windows_%26_Apache_without_403_on_Special_Pages, not sure if this is the right instructions I should be using.
Step 1 of the instructions indicate that "If you have vHosts configured, insert the following Rewrite directives into the appropriate <VirtualHost> directive. Otherwise, insert it in the <directory> directive for your wiki's root directory:" and to insert:
RewriteEngine On
RewriteRule ^/(.*):(.*) /index.php/$1:$2
Where is the <directory> directive located? What file should I be inserting the code into?
The <directory> block is a httpd.conf Apache configuration file directive.
On a shared hosting enviroment, you don't generally have directly access to his file. You still have access to an .htaccess file, which allows most configuration directives to be used.
Create a .htaccess at your web root (the same directory you have index.php and LocalSettings.php) and write the RewriteEngine / RewriteRules directives in this file.
If this fails, follow instead this guide, more adapted to your situation:
http://www.mediawiki.org/wiki/Manual:Short_URL/Apache
Related
I want to run a rewrite engine on my frontend servers (apache).
I have added this configuration
<If "-f 'PATH_TO_MY_LUA_SCRIPT'">
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteMap cust "prg:PATH_TO_MY_LUA_SCRIPT"
RewriteRule ^(.*)$ ${cust:%{REQUEST_URI}}" [QSA,L]
</IfModule>
</If>
But Apache says that RewriteMap not allowed here
PS : Of course PATH_TO_MY_LUA_SCRIPT is replaced by the full path (and my script is executable)
Has anyone used an external rewrite lua scriupt with Apache 2.4 ?
Of course, I forget to precise.
This conf is not in my .htaccess but in the main vhost config
See RewriteMap documentation
Context: server config, virtual host
And Context means
Context
This indicates where in the server's configuration files the directive is legal. It's a comma-separated list of one or more of the following values:
server config ...
virtual host ...
directory ...
.htaccess ...
The directive is only allowed within the designated context; if you try to use it elsewhere, you'll get a configuration error that will either prevent the server from handling requests in that context correctly, or will keep the server from operating at all -- i.e., the server won't even start.
So you cannot use RewriteMap in an .htaccess file, only in the main or in a virtual host configuration.
In this case If is causing the failure, because
Only directives that support the directory context can be used within this configuration section.
But RewriteMap may not be used in a directory context. So even if you have it in the main or virtual host configuration, you must not use it inside an If directive.
How can I set .htaccess to make
http://www.example.com/folder
go to (assuming this is not made automatically)
http://www.example.com/folder/ ?
For existing directories, Apache already provides a configuration option via mod_dir. Add the DirectorySlash directive to your main configuration file, or otherwise the root .htaccess file.
DirectorySlash on
See the documentation.
I'm using Joomla 2.5 and Apache and I have followed this steps:
1- mod_rewrite module is eneabled? YES
2- htaccess.txt renamed to .htaccess
3- set "Use URL Rewriting" to YES.
And this is what I get:
Not Found
The requested URL /about-us was not found on this server.
The web is located in /var/www/
The .htaccess is located in /var/www/
And this is my .htaccess: http://pastebin.com/dq1TYs1t
Thanks for the help.
Since you said allowoverride was set to none, your .htaccess file will be ignored. You need to set allowoverride to all the other option is leave allowoverride at none, and take the contents of the .htaccess file and incorporate it into your apache configuration file. This has the benefit of being slightly faster as apache doesn't need to look in directory tree for .htaccess files (they are really good to allow users that don't have access to the configs the ability to override the base settings, but if you have access to /var/www you should also have access to make changes to the config files.
There is no need to enable any mod_rewrite module.
Need to enable URL rewriting option in global configuration. Also need to rename htaccess.txt file to .htaccess.
please check there is no any third party component of security like admin tools are enable or installed which is blocking this mod rewrite option.
Is it possible to have just a single php.ini file, for example in the webroot (or even outside of it to prevent people accessing it via GET), and tell PHP quickly and easily where it is?
I know you can set php.ini directives in .htaccess, but is it possible to define a specific php.ini file to be used?
Add this to your server configuration...
<VirtualHost 1.2.3.4:80>
PHPINIDir /path/to/new/php_ini
</VirtualHost>
Make sure to just include the path to the directory, not the entire path to the file.
Then restart Apache.
Check it worked with phpinfo().
Have a look at .user.ini section at the php docs.
Since PHP 5.3.0, PHP includes support for .htaccess-style INI files on
a per-directory basis.
But beside the .unser.ini solution you can place an additional ini file in the "additional .ini files parsed" directory. There you can use one single ini file to overwrite all other settings. Name it with zzz at the beginning and it will be parsed at last. This is also easy for your hoster to deploy without destroying his settings.
Kolink, I suspect that you are on a shared hosting service, in which case your host may be using something called suPHP. In this case -- as you describe -- the PHPINIDir directive doesn't work, in which case there is a suPHP_ConfigPath directive.
In terms of access, I have a standard mod_rewrite in my DOCROOT/.htaccess:
RewriteEngine On
RewriteBase /
# if a forbidden directory or file name (starting with a . or /) then raise 404 Fatal
RewriteRule (^|/)[_.] - [F]
What this does is forbid any request for any filename or directory prefixed by . or _. I have a DOCROOT/_private where I keep this stuff for me:
suPHP_ConfigPath DOCROOT/_private
where you will need to replace DOCROOT by your local setting on your service. Look for DOCUMENT_ROOT in a phpinfo() listing.
I had mod_rewrite set on my server to rewrite a url like the following
http://www.example.com/1
to
http://www.example.com/index.php?show=1
In order words a URL shortern. Everything was working fine when the system was running under a sub-domain on my development site, but now it just generates a Not Found error, although if I manually enter the url /index.php?show=1 it works fine.
So the only changes is the urls switching from
http://www.site.example.com
to
http://www.site.com
however it's still running on the same server and the same sub-folder inside public_html on the server just the new domain name has been pointed to that folder.
The folder it's stored in is /public_html/paste
The full .htaccess file running in the directory is
# Set Default File
DirectoryIndex index.php
# Turn ReWrite Engine On
RewriteEngine on
# Create Rule To Write URLs To Shorter Versions
RewriteRule /([a-z0-9]+) /index.php?show=$1
I can't enable RewriteLog as the hosting doesn't allow it for some reason.
It sounds like the AllowOverride directive is not properly set for that folder. In your Apache configuration, you should make sure that the Directory or Vhost you're using for the primary domain has the AllowOverride set to All
http://httpd.apache.org/docs/2.0/mod/core.html#allowoverride
You probably need to specify the RewriteBase directive.
http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
I'll also note that Options +FollowSymlinks would be good to have in there too in case you ever turn it off further up the config chain (rewrite wont work without it).