Page 1 of 1

mod-rewrite for search engine optimisation

Posted: Tue Jun 27, 2006 3:44 pm
by okelly
I've rewritten the following into .htaccess so that the url http://www.mydomain.com/okelly/okelly01 ... ticleId=56 will be reproduced as http://www.mydomain/page56.htm but i'm getting a 404 error on Apache (win2000).

Q1. I've filed .htaccess to \htdocs\ Is this correct or does .htaccess go to \htdocs\okelly\
I've tried both & neither work

Q2. Have I coded this correctly?

Code: Select all

RewriteEngine on
RewriteBase /okelly
RewriteRule ^page([^.]+).*$okelly01.php?ArticleID=$1 [T=application/x-httpd-php]
Thanks in advance

Posted: Wed Jun 28, 2006 12:44 am
by RobertGonzalez
.htaccess goes into the folder closest to root that you want affected by it.

Code: Select all

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
# Skips the following S rules is they do not apply
RewriteRule ^.*$ - [S=1]
RewriteRule ^page([0-9]+).htm$ /okelly/okelly01.php?ArticleID=$1 [QSA,L]
</IfModule>
Put this is your root folder and try it. Remember also that when the URL is rewritten all relative paths within your output HTML with get thrown off, so make sure you use full URLs and paths to images, scripts and stylesheets or your output might look wonky.