[pmwiki-users] CleanUrls
Petko Yotov
5ko at 5ko.fr
Wed Feb 20 12:55:35 CST 2013
Maria McKinley writes:
> Is there a way to not have "pmwiki" show up in the url if you have .htaccess
> and pmwiki.php in the same directory? I'm thinking not, but wanted to verify.
Yes. Normally you have an index.php file which includes pmwiki.php (wherever
pmwiki.php is, in the same directory or elsewhere) and use URL rewriting to
redirect requests to index.php.
Here is a sample .htaccess which I use on many different sites:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([A-Z0-9\x80-\xFF].*)$ /index.php?n=$1 [QSA,L]
The RewriteCond lines limit the redirection only if the requested URL
isn't an actual filename or directory.
The above .htaccess and index.php are in the DOCUMENT_ROOT directory of the
server, and in the same directory are wiki.d/ and uploads/.
If your index.php file, wiki.d/ and uploads/ are in a subdirectory, for
example pmwiki/index.php, and you want your URLs to be like
www.shadlenlab.columbia.edu/Main/HomePage
then you need to edit the .htaccess file in the root directory, not the one
in the pmwiki/ subdirectory. Here is an example of such a working file:
RewriteEngine On
RewriteBase /
RewriteRule ^$ /pmwiki/index.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([A-Z0-9\x80-\xFF].*)$ /pmwiki/index.php?n=$1 [QSA,L]
The first RewriteRule line redirects www.shadlenlab.columbia.edu/ without
anything else to PmWiki, the last redirects anything that is not a file/dir
also to PmWiki.
The /pmwiki/index.php file includes pmwiki.php (wherever it may be) and sets
the $ScriptUrl variable and if needed, the $PubDirUrl, the $FarmPubDirUrl
and the $UploadsUrlFmt variables.
The first example works for me with HTTPS off, the second with HTTPS on,
without doing anything in particular.
> In a related question, any idea why this if statement would not work?
> # Set PmWiki paths according to the SSL mode
> if ($UrlScheme == 'https') {
> $ScriptUrl = "https://www.shadlenlab.columbia.edu/pmwiki";
> }
> else {
> $ScriptUrl = "http://www.shadlenlab.columbia.edu";
> }
>
> I always end up with the pmwiki in the url, regardless of whether I am using
> https or http.
I don't see why, it is possible that some of the $_SERVER variables of the
system are not correctly presented to PmWiki.
Petko
More information about the pmwiki-users
mailing list