Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
I've been working lately to add couch CMS to another website. +1 for awesome support my first time around. I never got around to adding pretty url's to the first site, but I figured I'd give it a shot here.

Upon extracting the .htaccess file from gen_htaccess.php, I appended it to my existing .htaccess file on the site's root and was hung up with a redirect error.

Following documentation has been reviewed:
http://docs.couchcms.com/concepts/pretty-urls.html

Following forum topics have been reviewed and methods tested:
viewtopic.php?f=4&t=9550
viewtopic.php?f=4&t=4254
viewtopic.php?f=2&t=7388

Checks:
Is modrewrite enabled? Yes
Is apache > version 1.x? Yes v.2.2.29

Additional information

The site is currently being rerouted from it's initial directory of public_html to websites/mysite/(site hosted here).

The .htaccess mod rewrite code is listed below (from public_html folder).

NOTE: MYSITE.COM ADDED TO CODE FOR CONFIDENTIALITY PURPOSES

Code: Select all
# .htaccess main domain to subdirectory redirect
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/websites/mysite/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /websites/mysite/$1
# Change example.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteRule ^(/)?$ websites/mysite/index.php [L]


.htaccess file in /websites/mysite/.htaccess has the following rules to battle recent xss script attack on server.

SPECIAL NOTE: XSS SCRIPT INJECTION WAS FIRST NOTED MID AUGUST. SITE HAS BEEN DUMPED AND REBUILT FROM GROUND UP SINCE. SITE DID NOT HAVE COUCH INSTALLED PRIOR TO INFECTION. COUCH WAS RECENTLY ADDED TO NEW REDESIGN LAUNCHED POST INFECTION WITH APPROPRIATE COUNTERMEASURES ADDED. REWRITES BELOW SOLE PURPOSE ARE TO HELP EXPEDITE REMOVAL OF DEAD LINKS FROM GOOGLE, BING, ECT.

Code: Select all
# redirect .pdf and directories to 410 response 
   RewriteRule \.pdf$ - [G]
   RewriteRule \.swf$ - [G]
   RewriteRule ^infect/ - [G]
   RewriteRule ^o59miv707/ - [G]
   RewriteRule ^k4q65l11x/ - [G]
   RewriteRule ^vihsidob2va/ - [G]
   RewriteRule ^4ghr3vpb1/ - [G]
   

#Deny Image index and PDF index
<Files ~ "\.pdf$">
  Header set X-Robots-Tag "noindex, nofollow"
</Files>

<Files ~ "\.(png|jpe?g|gif)$">
  Header set X-Robots-Tag "noindex"
</Files>


Config File was as follows (reverted back to no pretty urls pending investigation). NOTE: Apparently the mod rewrite to change the initial directory for the site listed above required modifying the K_Site_URL to what is currently listed below for couch cms to work in the first place (puts me in the "special cases" apparently).

// 1.
// If necessary, define the full URL of your site including the subdomain, if any.
// V.IMP: Don't forget the trailing slash!
define( 'K_SITE_URL', 'http://www.mysite.com/' );

// 8.
// Set the following to '1' if you wish to enable Pretty URLS.
// After enabling it, use gen_htaccess.php to generate an .htaccess file and place it in the root folder of your site.
define( 'K_PRETTY_URLS', 1 );

To recap, the following behaviors were recorded by the server. Internal 500 error at first, redirection in a way the server can never process secondary (infinite loop syndrome).

Any help would be greatly appreciated, but since this is a personal site, rush assistance is not required. If you would like additional information about my setup, let me know and I can provide further details. Brain's burnt out for now.
Hi :)

I suggest you please first try out the Couch generated .htaccess file alone (we can add the existing rules you have for the site once we get this working).

To do that, rename your existing .htaccess and put in only the Couch specific file. Please let me know how it goes.
KK, Thanks for the speedy reply!

After removing all extraneous information from the .htaccess files for the site, I'm left with a redirect error. The following steps were taken:

1.)Enable prettyurls in config file
2.)Remove everything from .htaccess files in root and site.

root htaccess looks like this (required for site to be hosted in subdirectory):

Code: Select all
# .htaccess main domain to subdirectory redirect
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/websites/mysite/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /websites/mysite/$1
# Change example.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteRule ^(/)?$ websites/mysite/index.php [L]


3.)generate htaccess for pretty urls using gen_htaccess.php:

Code: Select all
Options +FollowSymlinks -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On

#If your website is installed in a subfolder, change the line below to reflect the path to the subfolder.
#e.g. for http://www.example.com/subdomain1/subdomain2/ make it RewriteBase /subdomain1/subdomain2
RewriteBase /

#If you wish to use a custom 404 page, place a file named 404.php in your website's root and uncomment the line below.
#If your website is installed in a subfolder, change the line below to reflect the path to the subfolder.
#e.g. for http://www.example.com/subdomain1/subdomain2/ make it ErrorDocument 404 /subdomain1/subdomain2/404.php
#ErrorDocument 404 /404.php

#If your site begins with 'www', uncomment the following two lines
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]


#DO NOT EDIT BELOW THIS

RewriteRule ^index.php$ "" [R=301,L,QSA]

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule . - [L]

#blog.php
RewriteRule ^blog$ "$0/" [R=301,L,QSA]
RewriteRule ^blog/$ blog.php [L,QSA]
RewriteRule ^blog/.*?([^\.\/]*)\.html$ blog.php?pname=$1 [L,QSA]
RewriteRule ^blog/([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$ blog.php?d=$1$2$3 [L,QSA]
RewriteRule ^blog/[^\.]*?([^/\.]*)/$ blog.php?fname=$1 [L,QSA]
RewriteRule ^blog/[^\.]*?([^/\.]*)$ "$0/" [R=301,L,QSA]

#blog-template.php
RewriteRule ^blog-template$ "$0/" [R=301,L,QSA]
RewriteRule ^blog-template/$ blog-template.php [L,QSA]
RewriteRule ^blog-template/.*?([^\.\/]*)\.html$ blog-template.php?pname=$1 [L,QSA]
RewriteRule ^blog-template/([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$ blog-template.php?d=$1$2$3 [L,QSA]
RewriteRule ^blog-template/[^\.]*?([^/\.]*)/$ blog-template.php?fname=$1 [L,QSA]
RewriteRule ^blog-template/[^\.]*?([^/\.]*)$ "$0/" [R=301,L,QSA]

#index.php
RewriteRule ^.*?([^\.\/]*)\.html$ ?pname=$1 [L,QSA]
RewriteRule ^([1-2]\d{3})/(?:(0[1-9]|1[0-2])/(?:(0[1-9]|1[0-9]|2[0-9]|3[0-1])/)?)?$ ?d=$1$2$3 [L,QSA]
RewriteRule ^[^\.]*?([^/\.]*)/$ ?fname=$1 [L,QSA]
RewriteRule ^\w[^\.]*?([^/\.]*)$ "$0/" [R=301,L,QSA]
</IfModule>


4.)For clarity purposes, accessing the site with the generated code (NO MODIFICATIONS) produces a 500 internal error.

5.)Modify htaccess file with subdirectory information
Code: Select all
#If your website is installed in a subfolder, change the line below to reflect the path to the subfolder.
#e.g. for http://www.example.com/subdomain1/subdomain2/ make it RewriteBase /subdomain1/subdomain2
RewriteBase /websites/mysite


6.)Access site again, receive "The page isn't redirecting properly"

7.)Modify htaccess files by deleting
Code: Select all
Options +FollowSymlinks -MultiViews


8.)Access site again, receive "The page isn't redirecting properly"

I've tried a few other configurations with no success. It may be necessary to look further into the htaccess code in the root that redirects the site to a subdirectory of my choosing.

Additional information:
Hosting - Bluehost
Hosting your site on a subdirectory (I believe this may be the root of the problem):
https://my.bluehost.com/cgi/help/347

Any additional help would be greatly appreciated.
Hi,

Would it possible for you to access the web server's error log? Please see what is being reported there (for 500 error as well as the redirection).

If it is ok, please PM me your site's FTP + Couch access creds and I'll be glad to take a look at the problem.
Update to anyone else following this thread... The issue was relative to an erranously populated index.php rewrite rule.

Once the following lines were commented out

Code: Select all
#DO NOT EDIT BELOW THIS
#RewriteRule ^index.php$ "" [R=301,L,QSA]


the rewrite and Pretty URLs worked like a charm. Many thanks to KK for helping me out on this.
5 posts Page 1 of 1