mod-rewrite for search engine optimisation

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
okelly
Forum Commoner
Posts: 29
Joined: Thu Feb 23, 2006 2:18 pm

mod-rewrite for search engine optimisation

Post 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
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
Post Reply