Forum Moderators: phranque

Message Too Old, No Replies

.htacess help for friendly urls

.htaccess friendly url

         

pjb1997

3:16 pm on Jan 16, 2005 (gmt 0)

10+ Year Member



Hello, I just joined the forum and I am very much a total newbie in trying to work with .htaccess.

I have a site where I want to use friendly urls for dynamically generated pages, particluarly in a calendar control on my blog, and so far I am only partially successful.

Using an .htaccess file that was recommended to me, I have been able to change the following url (that displays archived entries by months)

http://mysite.com/blog/index.php?blogid=1&archive=2005-1

to

http://mysite.com/blog/archive-1-2005-01.html

But I have not figured out a way to change the following url (that displays archived entries for individual days)

http://mysite.com/blog/index.php?blogid=1&archive=2005-1-8

to

http://mysite.com/blog/archive-1-2005-01-8.html

I really don't know regular expressions, or .htaccess, but I have tried to hack away at it without success. Here is my .htaccess file so far:

###################################################


RewriteEngine On

# The next line is for selecting individual months in the calendar control and archives--it is working

RewriteRule ^archive-([0-9]+)-([0-9]+)-([0-9]+).html+ index.php?archive=$2-$3&blogid=$1

RewriteRule ^item-([0-9]+).html+ index.php?itemid=$1
RewriteRule ^archivelist-blog.html+ index.php?archivelist=$1
RewriteRule ^cat-([0-9]+)-([0-9]+).html+ index.php?catid=$1&blogid=$2

# The last two lines are for selecting individual dates in the calendar control but it is not working.
# I know the RewriteCond line works, because it traps the condition okay--but the last line is FUBAR

RewriteCond %{REQUEST_URI} archive-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+).html
RewriteRule ^archive-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+).html+ index.php?archive=$2-$3&blogid=$1-$5&itemid=$4


###################################################

If anybody could please help, it would be fantastic!

Thanks,

Phil

pjb1997

6:06 pm on Jan 16, 2005 (gmt 0)

10+ Year Member



A friend helped me out: I changed the last line to:


RewriteRule ^archive-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+).html+ index.php?archive=$2-$3-$4&blogid=$1

Everything works now!

Phil

jdMorgan

4:10 pm on Jan 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Phil,

Welcome to WebmasterWorld!

Glad you got it working.

Jim