Jump to content

HELP! SEO Friendly URL Structure Using .htaccess


aweb

Recommended Posts

I am struggling to get a basic mod_rewrite working with my .htaccess. I will add first that mod_rewrite is enabled on my server, I am uploading .htaccess in ANSI, and I have no problem getting rules such as force www working.

 

My problem is that I cannot get "remove .php from url" to work nor can I can rewrites working for my dynamic urls. Here is what some of my .htaccess looks like:

 

Start:

Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /

 

I tried using the following so that, for example, category 13, would be show up: http://www.example.com/newname

RewriteCond %{QUERY_STRING} ^id=13$
RewriteRule ^/categories.php$ http://www.example.com/newname [L,R=301]

 

Since I got no response from that above, I tried this:

Redirect 301 /categories.php?id=27$ http://www.example.com/
RewriteRule ^new-title$ categories.php?id=27 [nc]]

 

Now, I can point to the url http://www.example.com/new-title and that works fine but for some reason the redirection isn't working...

 

Also while we are at it, this isn't working at all either:

 

#####################################
# Remove file extension and force trailing slash
#####################################

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

 

Any help would be appreciated!

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.