I would like to remove the .html off the end of my entry urls. For me the whole point to using mod_rewrite is to make my urls pretty, tossing on a .html on the end defeats that for me.
ie, it currently is:
http://domain.com/archives/57-entry.html
and I would like just:
http://domain.com/archives/57-entry
I have tried mucking around with the .htaccess rules with no luck. http://domain.com/archives/57-entry will just show all entries instead of entry 57. Any idea how to accomplish this?
mod_rewrite and .html
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: mod_rewrite and .html
Okay. I'll tell you the modifications for Serendipity 0.8. They basically also apply to 0.7, but in 0.7 you will find the files in different directories.
1. Open your include/tpl/htaccess_rewrite.tpl file
2. Modify those patterns:
to this:
2. Open your serendipity_config.inc.php file. Change those constants:
into this:
If you're using 0.7 you will also need to open serendipity_functions.inc.php and change function serendipity_archiveURL() into:
3. Then go to Serendipity configuration, set your URL Rewriting to None, Save, set it to 'mod_rewrite' and save again. This will recreate your .htaccess with your new htaccess_rewrite.tpl settings.
Then it should work. Note that however searchengines like google will now score your URLs lower, because at the moment .html files have higher precedence than a path name.
Regards,
Garvin
1. Open your include/tpl/htaccess_rewrite.tpl file
2. Modify those patterns:
Code: Select all
RewriteRule ^{PAT_ARCHIVES} {indexFile}?url=/{PATH_ARCHIVES}/$1.html [L,QSA]
RewriteRule ^([0-9]+)[_\-][0-9a-z_\-]*\.html {indexFile}?url=$1-article.html [L,NC,QSA]
Code: Select all
RewriteRule ^{PAT_ARCHIVES} {indexFile}?url=/{PATH_ARCHIVES}/$1 [L,QSA]
RewriteRule ^([0-9]+)[_\-][0-9a-z_\-]*{indexFile}?url=$1-article [L,NC,QSA]
Code: Select all
@define('PERM_ARCHIVES', '%id%-%title%.html');
@define('PAT_ARCHIVES', '@/'.PATH_ARCHIVES.'([/A-Za-z0-9]+)\.html@');
@define('PAT_COMMENTSUB', '@/([0-9]+)[_\-][' . PAT_FILENAME . ']*\.html@i');
Code: Select all
@define('PERM_ARCHIVES', '%id%-%title%');
@define('PAT_ARCHIVES', '@/'.PATH_ARCHIVES.'([/A-Za-z0-9]+)@');
@define('PAT_COMMENTSUB', '@/([0-9]+)[_\-][' . PAT_FILENAME . ']*@i');
Code: Select all
function serendipity_archiveURL($id, $title, $key = 'baseURL', $checkrewrite = true) {
global $serendipity;
return $serendipity[$key] . ($checkrewrite && $serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . PATH_ARCHIVES . '/' . (int)$id . '-' . serendipity_makeFilename($title);
}
Then it should work. Note that however searchengines like google will now score your URLs lower, because at the moment .html files have higher precedence than a path name.
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/