|
Cookbook /
CleanUrls-TalkThis page contains all comments from the CleanUrls page. Renaming to shorten URLsI'm new to PmWiki, but what I did was this:
## Eliminate "pmwiki.php" from URLs.
$EnablePathInfo = 0;
$ScriptUrl = "http://put your domain name here/w/i.php";
## more configuration settings...
Finally, I pointed my server to i.php and it worked with a short URL! Ok,I tried this exact process (with a Windows server) and this is what I got "Warning: Cannot modify header information - headers already sent by (output started at E:\xampp\htdocs\wikifolder\myinformation.php:1) in E:\xampp\htdocs\wikifolder\pmwiki.php on line 1075," can someone advise? thanks! -Chris August 24, 2008 Solved the same problem thanks to PM > The "Cannot modify header information" probably comes from some > extra characters or blank lines at the beginning of index.php, before > the "<?php" tag. > > Pm http://www.mail-archive.com/pmwiki-users@pmichaud.com/msg12201.html Damien September 16, 2008, at 02:10 AM Trying to remove pmwiki.php with .htaccessI'm trying to remove the pmwiki.php using .htaccess but have so far failed, hopefully you guys can help me out. In my config file I have: ## Use "Clean URLs". $EnablePathInfo = 1; $ScriptUrl = "http://www.mydomain.com/necrowiki"; ## more configuration settings... Then in my .htaccess file, which is located in the same dir as pmwiki.php: # Use mod_rewrite to enable "Clean URLs" for a PmWiki installation. RewriteEngine On # Define the rewrite base. RewriteBase /necrowiki # Send requests without parameters to pmwiki.php. RewriteRule ^$ pmwiki.php [L] # Send requests for index.php to pmwiki.php. RewriteRule ^index\.php$ pmwiki.php [L] # Send requests to pmwiki.php, appending the query string part. RewriteRule ^([^/a-z].*) pmwiki.php?n=$1 [QSA,L] Anybody know why it isn't working? Remove www from URLAlso add this and you will remove the www from all URLs for your site. It is completely compatible with CleanUrls.
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
Lowercase Group NamesDoes anyone know how to use rewriting capabilities to allow lower-case group names to be entered and successfully redirected to the title-cased group names? e.g. Yes, the rewrite rule should be RewriteRule ^([^/].*) pmwiki.php?n=$1 [QSA,L] instead of RewriteRule ^([^/a-z].*) pmwiki.php?n=$1 [QSA,L] which just means the page name can't start with a forward slash, but anything else is fine. — Sam Wilson 2007-02-02. hi. thanks for this. i'm using lowercase group and pagenames as well, and this solved a huge problem. however, in my case i discovered that while it enabled the mod_rewrite to finally occur for 'group.name', all of my css formatting was being lost. this was fixed when i put an exception for '/pub' in there (and for '/uploads' as well so that i could link directly to my files:
now it works great for me. special thank to PeterBowers for helping me figure out the pub & uploads regex exclusions... overtones99 October 01, 2009, at 03:13 AM Even cleaner URLsI also use the following (plus some modifications of php code) to get even cleaner URLs: # If of form Group/Name/action, # send requests to pmwiki.php with proper arguments appended ($3 is query string) RewriteRule ^([A-Z0-9][^/.]*[/.][^/]*)[/]([a-z]+)(.*) pmwiki.php?n=$1&action=$2&args=$3 [QSA,L] # Send requests to pmwiki.php, appending the query string part. RewriteRule ^([^/a-z].*) pmwiki.php?n=$1 [QSA,L] 2006-03-23 AriEpstein
Simplify further for group main pages ## Even cleaner URLs: group main pages display as /$group and not /$group/$group $EnableFixedUrlRedirect=0; $FmtPV['$PageUrl'] = '($name==$group) ? "$ScriptUrl/$group" : "$ScriptUrl/$group/$name"'; 2007-08-09 EemeliAro
Sam Brenner 2-7-2006 In your http.conf file uncomment: #LoadModule rewrite_module modules/mod_rewrite.so
or you will get an "Internal Server Error" message. Then you will have to enable the use of .htaccess Someone recommended using the following script directories as an alternative to hardcoding the servername. $BaseUrl = 'http://'.$_SERVER['HTTP_HOST']; $ScriptUrl = $BaseUrl.'/pmwiki'; $PubDirUrl = $BaseUrl.'/pmwiki/pub'; $UploadDir = '/uploads'; $UploadUrlFmt=$BaseUrl.'/pmwiki/uploads'; Using the $_SERVER[HTTP_HOST] variable solved a Netscape localhost name issue. For recent PmWiki releases you should be able to replace the five lines above with
$ScriptUrl = 'http://'.$_SERVER['HTTP_HOST'].'/pmwiki'; $PubDirUrl = 'http://'.$_SERVER['HTTP_HOST'].'/pmwiki/pub'; $UploadDir = '/uploads'; although that $UploadDir setting looks incorrect. Try leaving that line out, or replacing it with
$UploadDir = realpath($UploadDir = dirname(__FILE__).'/../uploads'); --Hagan
Thank you for all the work on this. The URL Rewriting (mod_rewrite + .htaccess) is so clear that I was able to immediately see what I broke when I moved my pmwiki directory down a level. --Pico
Clean URLs in WikiFarmsAm I correct in concluding that each Wiki Field would need its own distinct .htaccess file to ensure that each field queries itself? When you say to "place the .htaccess file in the directory that will correspond the shortest URL that will reach the wiki" does that mean, in the context of WikiFarms, the directories that correspond to the shortest URLs that will distinctly reach one (and only one) Farm? See here for more. --Pico
Yes, each field wiki needs its own distinct .htaccess because each field wiki has its own distinct URL. Does this rewrite of the note about farms make that point clearer? --Hagan
Another thing to check is the Apache error log.
For example you may see the error message
I tried approach #3, first (simple suggestion, Eliminating "pmwiki.php" From URLs), but the shortened URLs did not display the desired pages. It seems that index.php was not processed. Maybe this recipe requires certain webserver settings to work that are not in place on my server? I noticed that I also had to remove the trailing slash, or the path names would be displayed as Henning March 24, 2006, at 09:22 AM
Henning, This brings up an important point because you can (sometimes) use index.php + Before: http://www.example.com/~someuser/pmwiki/pmwiki.php?n=Main.HomePage After: http://www.example.com/~someuser/index.php/Main/HomePage Here's an index.php file for the corresponding directory (/home/someuser/public_html/):
<?php
chdir('pmwiki');
include_once('pmwiki.php');
Here's the matching local/config.php file, which simply turns on
<?php if (!defined('PmWiki')) exit();
## Use "Clean URLs".
$EnablePathInfo = 1;
## more configuration settings...
--Hagan The samedir mod-rewrite method breaks links to http://site.com/path/to/pmwiki.php?action=blah, apparently causing POST data to be dropped. A direct link to [blah]/pmwiki.php?action=login and [blah]/pmwiki.php?action=mailform2 (see Mailform2) causes both of these actions to fail. This quote from Mailform2 may be helpful: If you applied the CleanUrls recipe and have a redirect rule installed, make sure that the ?action=mailform2 URL above goes to the "unclean" URL (the one that contains pmwiki.php). Otherwise, form input data will be dropped by Apache, and all you'll get is seemingly empty input fields.
This is happening with the samedir mod-rewrite method regardless of whether the link (in the case of ?action=login) or the form (in the case of Mailform2) is directed to the "unclean" URL. -- Neurophyre, 7 Aug 2006 'RewriteRule ^index\.php$ ~someuser/pmwiki/pmwiki.php [L]' doesn't work on Aplus.netI'm hosting a wiki on aplus.net, and it seems that '^index\.php$' doesn't work as expected. 'RewriteRule ^index.php$ ~someuser/pmwiki/pmwiki.php [L]' works as expected, but it also rewrites 'index_php', 'indexQphp'... Shigeru Kobayashi December 28, 2006, at 09:29 AM
ISAPI module link brokenThe link to iismods.com generates an error (Bad Request (Invalid Hostname)). A little googling turned up Ionic's ISAPI Rewrite Filter which is free but not open-source. I've no idea whether the .ini syntax modeled on the CleanURLS page is compatible or not. Alas, I'm in a shared IIS hosting environment and can't use it. -thomas taylor, 03/05/2007 Minimum required "Options" for mod_rewritethe web server I use is very restrictive by default. The apache option Options +FollowSymLinks
99% of the people out there won't need this, but for the other 1%, here you go. Without this you will get a "403 Forbidden" error message --Vrillusions June 04, 2007, at 10:46 AM Even cleanerSome people might also be interested in GetRidOfMain. I had a hard time finding it. Jeff 7/19/07 It keeps renaming lowercase urls to group names - PauloI'm using pmwiki on the root of my site and have this line on my .htaccess:
I thinks this Regular Expression doesn't work at all because it ignores casing. The best Regex would be: ^([A-Z][a-z\xa0-\xff].*)$ I had problems to access sub-directories in the root of my website (like: domain.com/forum). This regex matches only the strings that starts with uppercased letters and then, sends to pmwiki.php. Showing images have been used in skin when using clean UrlsWhen you use clean urls with it will not show pictures have been set relative to pmwiki.php. To solve this problem you should add a line before the line sends parameters to pmwiki so those lines will be like the following: RewriteRule ^([A-Z0-9\xa0-\xff].*\.(jpg|gif))$ $1 [L]
RewriteRule ^([A-Z0-9\xa0-\xff].*)$ pmwiki.php?n=$1 [QSA,L]
This works except when you want to upload a picture so if you want to upload a picture the parameters won't be sent and you can't do it so a better regex for eliminating this problem is appreciated.Soroush mod_rewrite with Apache 1.3 on WindowsWhen using Apache 1.3 on Windows, the RewriteRule for CleanUrls does not work properly, since Apache 1.3 always lowercases the URI before providing it to mod_rewrite. This does not work (the original recipe with .htaccess and pmwiki.php in the Same Directory): RewriteBase /pmwiki RewriteRule ^([A-Z0-9\xa0-\xff].*)$ pmwiki.php?n=$1 [QSA,L] Change it to
RewriteBase /pmwiki
RewriteCond %{REQUEST_URI} ^/pmwiki/[A-Z0-9\xa0-\xff]
RewriteRule ^(.*)$ pmwiki.php?n=$1 [QSA,L]
Important: The path at RewriteBase and RewriteCond must be equal (here: /pmwiki). Wrapper using SetHandler (similar to "Wrapper using MultiViews")The web server that my account is on, for whatever reason, has MultiViews (and RewriteEngine) disabled, and of course, I can't override. I found another approach to creating a "wiki" wrapper. First, I create a php wrapper called just "wiki" with no extension, same contents as the MultiViews "wiki.php" wrapper. Then, I add the following to my .htaccess to force just this file to be handled as php. <FilesMatch "^wiki$">
SetHandler application/x-httpd-php
</FilesMatch>
The other steps are the same as the MultiViews wrapper. The final URL looks like this: http://www.example.com/~someuser/wiki/Main/HomePage -Steve March 21, 2009 Which .htaccess file are you talking about? Where do you put this "wrapper" file? Is it just a .php file with only those three lines in it?
Remove Main from URLs (using a RewriteRule and GetRidOfMain)Note: GetRidOfMain is required for this to work completely (I have only tested this using the first GetRidOfMain method). This RewriteRule fixes GetRidOfMain by correctly linking to non-existent pages. This assumes you are already using CleanUrls' URL Rewriting Example 3. In the .htaccess file, replace: # Send requests to pmwiki.php, appending the query string part. RewriteRule ^([A-Z0-9\xa0-\xff].*)$ pmwiki.php?n=$1 [QSA,L] with: #Send single name pages to pmwiki.php?n=Main.$1 RewriteRule ^([A-Z0-9\xa0-\xff][^\.\/]*(\?.*)?)$ pmwiki.php?n=Main.$1 [QSA,L] # Send requests to pmwiki.php, appending the query string part. RewriteRule ^([A-Z0-9\xa0-\xff].*)$ pmwiki.php?n=$1 [QSA,L]
Hello. Which .htaccess file are you talking about? So, which method works best with a normal hosted wiki? I use NFS.net if anyone's had experience doing this. I simply can't follow all the abstruse technical instructions above and on the CleanURLs page; please can someone help explain? cheers
|