Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
I am running into a cosmetic and SEO problem here. I have the CouchCMS blog set up with pretty urls (which I've noticed redirects blog.php to blog/) via config.php and .htaccess. The code in my .htaccess, which removes .php from all the urls on my site, conflicts with the new code supplied by CouchCMS.

So far I have only been able to get my site working in one of two ways:
1) Hide .php from the end of all main pages but lose out on the SEO and cosmetic value of pretty urls
2) Show .php at the end of all main pages but get pretty urls

Neither of those two scenarios are going to be good for our current SEO strategy (all current links are point to urls without an extension). What I want is all the pages on my site outside of the blog to show without .php while the blog still displays pretty urls.

I have tried creating individual redirects for my pages in .htaccess (redirect /about.php http://www.mysite.com/about) but Couch's pretty url code won't allow them to redirect.

In a worst case scenario I'm going to have to ditch pretty urls because the aesthetics and SEO on my main pages is more important. However, I really don't want to display blog.php?ugly=url2 when they go to a blog article.

Has anyone found a way to modify their .htaccess to accommodate this?
Hi,

So what does your original .htaccess (without putting any rules for Couch templates) look like?
I'd want to take a look at it in full so you can PM it to me if you don't want to post it here.

Thanks.
Hi,

Sorry for the delay in my reply.

Thanks for PMing me the pre-Couch .htaccess rules.
The most important part of those was this section where we essentially check if a .php file exists with the name specified in the URL
Code: Select all
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]

Unfortunately, as you observed, this generic rule plays foul with the rules used by Couch generated .htaccess file.

With some experimentation, I found the following alternative to work the same. Perhaps you'd want to use this in lieu of the original code -

I had to explicitly specify the names of the non-Couch php files just above the "#DO NOT EDIT BELOW THIS" line of Couch generated .htaccess file
Code: Select all
#test
RewriteRule ^(tom|dick|dirty/harry)$ "$1/" [R=301,L,QSA]
RewriteRule ^(tom|dick|dirty/harry)/$ $1.php [L,QSA]
#end test

#DO NOT EDIT BELOW THIS

The code above specifies three files
tom.php
dick.php
dirty/harry.php

that can be accessed as
tom/
dick/
dirty/harry/

This worked well while not interfering with the Couch templates.

Hope this helps.
Do let us know.

Thanks.
Thank you for the fix KK, it works! This will be very difficult to keep up the more pages I add. If there a more generic fix I'd appreciate that. Otherwise every time I add a page it will have to be added to the list.

But good for a temporary fix.

Thanks much : )
4 posts Page 1 of 1