.htaccess confusion

Status
Not open for further replies.

shaistar

New Member
Messages
25
Reaction score
1
Points
0
Ok so I've been spending a couple of days trying to make seo friendly urls.

This is what my .htaccess file looks like now.

<IfModule mod_rewrite.c>

Options +FollowSymlinks
RewriteEngine on
RewriteBase /

RewriteRule ^category index.php

RewriteCond %{HTTP_HOST} ^example\.co.cc$ [NC]
RewriteRule ^(.*)$ http://www.example.co.cc/$1 [R=301]


</IfModule>

I've tried rules upon rules in different combinations from all over the internet. I tried testing it on my home testing server and I tried uploading thru ftp onto my free account. None of the rules that i tried work at all on either one except the second one. I went to corz.org dude, I read the Apache manual, and I searched the forms... nada. I even copied and pasted to make sure I didn't mess up and insert the data that applied to my website.

I want my url to look like this
http://www.confused.co.cc/example/something-else

My php dynamic urls look like this now:
http://www.confused.co.cc/index.php?section=example&page=something-else

If anybody could lend a helping hand it will be greatly appreciated.
hello?

If it helps I have an index.php file with a script to include files. If it matters...
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Step 1: Turn the engine on and set the base (especially where you have virtual hosts)


Code:
RewriteEngine on
RewriteBase /


Step 2: Make sure that the request isn't for a file or directory:

Code:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

The !-f means not a file and !-d means not a directory


Step 3. Change foo/bar into index.php?section=foo&page=bar

Code:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.+)/(.+) index.php?section=$1&page=$2 [L]

. = any character
.+ = 1 or more of any character
(.+) = group answer for later reference as $1
(.+)/(.+) = captures front and back strings into $1 and $2
 
Status
Not open for further replies.
Top