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!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.