You are here:  » Rewriterule help

Support Forum



Rewriterule help

Submitted by jr on Thu, 2007-10-11 11:22 in

Apologies in advance, cos I know this isn't a price tapestry issue but I hope you can help...

I've added a simple blog into a new price tapestry install that I'm working on.

So I've got blog.php in the site root and if I go to www.mydomain.com/blog.php I can see all blog posts.

If I go to www.mydomain.com/blog.php?article=example_article_title I can see a single blog post. This all works fine.

I've tried adding stuff to htaccess to get nice looking URLs but I can't get it to work. For example, I thought this simple rule should at least show www.mydomian.com/blog/ but it doesn't seem to work:

RewriteRule ^blog/$ blog.php

All your rules work fine. Am I doing something wrong?

Thanks in advance
John

Submitted by support on Thu, 2007-10-11 11:27

Hi John,

It looks OK - what actually happens when you go to /blog/ ?

Do you get a 404, exactly as if you went to /foo/ ? Or is it an internal server error?

Cheers,
David.

Submitted by jr on Thu, 2007-10-11 11:36

Hi David

Thanks for the reply.

There are no errors. I just get www.mydomain.com/blog.php in the browser bar

Cheers
John

Submitted by support on Thu, 2007-10-11 11:39

Hi John,

That indicates that it is doing a redirection rather than a rewrite. Can you post your entire .htaccess as the behavior of RewriteRule's depends on other entries in the file...

Cheers,
David.

Submitted by jr on Thu, 2007-10-11 11:45

Ok here goes:

Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^product/(.*).html$ products.php?q=$1&rewrite=1&%{QUERY_STRING} [L]
RewriteRule ^blog/$ blog.php
RewriteRule ^review/(.*).html$ reviews.php?q=$1&rewrite=1&%{QUERY_STRING} [L]
RewriteRule ^merchant/$ merchants.php
RewriteRule ^merchant/(.*)/$ search.php?q=merchant:$1:&rewrite=1%{QUERY_STRING} [L]
RewriteRule ^merchant/(.*)/(.*).html$ search.php?q=merchant:$1:&page=$2&rewrite=1%{QUERY_STRING} [L]
RewriteRule ^category/$ categories.php
RewriteRule ^category/(.*)/$ search.php?q=category:$1:&rewrite=1%{QUERY_STRING} [L]
RewriteRule ^category/(.*)/(.*).html$ search.php?q=category:$1:&page=$2&rewrite=1%{QUERY_STRING} [L]
RewriteRule ^brand/$ brands.php
RewriteRule ^brand/(.*)/$ search.php?q=brand:$1:&rewrite=1%{QUERY_STRING} [L]
RewriteRule ^brand/(.*)/(.*).html$ search.php?q=brand:$1:&page=$2&rewrite=1%{QUERY_STRING} [L]
RewriteCond %{HTTP_HOST} ^mydomain.co.uk [NC]
RewriteRule ^(.*)$ http://www.mydomain.co.uk/$1 [L,R=301]
ErrorDocument 404 /not_found.php
AddHandler php4-script .php

Submitted by support on Thu, 2007-10-11 12:14

Hi John,

I think I can see the problem....

You haven't specified "Last Rule" (using [L]), so it is being caught by the blanket redirect at the bottom. Try this:

RewriteRule ^blog/$ blog.php [L]

That should do the trick!
Cheers,
David.

Submitted by jr on Thu, 2007-10-11 13:30

Thanks for your help :)