Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

mod rewrite: url with a dot not redirecting

2:37 am on Nov 28, 2011 (gmt 0)

New User

10+ Year Member

joined:May 26, 2005
posts: 35
votes: 0


We have a weird case of where our htaccess is not kicking in when it should.

The path example being /shopping/some-path-name-5.5/100/1

The page should be redirecting to /shopping/some-path-name-55/100/1, but it's showing a 404 instead.

We are running cpanel.

Below is an abridged output of our htaccess file (w start off by catching old file paths, and redirecting to the new as we have migrated systems).

Any help is greatly appreciated. Thanks a lot.

RewriteEngine on

RewriteRule .*/(.*)/p/(.*)/$ /products/$1/$2/1 [L,R=301]
RewriteRule .*/(.*)/p-(.*)$ /products/$1/$2/1 [L,R=301]
RewriteRule .*/(.*)/c/(.*)/page/(.*)/$ /shopping/$1/$2/1 [L,R=301]
RewriteRule .*/(.*)/c-(.*)$ /shopping/$1/$2/1 [L,R=301]
RewriteRule .*/(.*)/g-(.*)-page-(.*)$ /shopping/$1/100$2/$3 [L,R=301]
RewriteRule .*/(.*)/g/(.*)/page/(.*)/$ /shopping/$1/100$2/$3 [L,R=301]

RewriteCond %{REQUEST_URI} !\.
RewriteCond %{REQUEST_URI} !//

RewriteRule (.*)/(.*)/(.*)/(.*) $1.php?id=$3&page=$4&name=$2 [L,QSA]
5:39 am on Nov 28, 2011 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

joined:Apr 9, 2011
votes: 244

:: runs around for a few minutes screaming in horror ::

Last week I was faced with the rhetorical query: What's worse than an initial (.*) ? Two initial (.*) sets. Now in one fell swoop we've got FOUR.

:: pause for some more screaming ::

What is the .* meant to cover? If it's a single directory name, you want [^/]+. That's + not * unless your site is weighted down with malformed URLs along the lines of

www.example.com///g//page// (rule 6)
www.example.com//g--page- (rule 5)

By the time you've executed those first six rules-- assuming your server is still standing-- what's left for the final Rule and its Conditions?


... should be redirecting to


I'm getting a headache. Which of your rules 4-6 (the three that redirect to /shopping/ and don't exclude literal periods) is supposed to have this result?

RewriteCond %{REQUEST_URI} !//

Seems a bit superfluous, since your first six Rules all allow for // and even ///

:: sob ::
8:08 am on Nov 28, 2011 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
votes: 0

There's only three things right with your initial code.
You have correctly listed redirects before rewrites.
You have correctly used the R=301 flag.
Every rule correctly has the L flag.

There are however, multiple serious problems.
First, the redirect target should include the protocol and domain name to avoid duplicate content issues.
Second, please read everything that has been said here over the last decade about not using the (.*) grouping at the beginning or in the middle of a RegEx pattern and about never using more than one (.*) in a pattern.
Thirdly, unless you want your server hacked by opportunists, that $1.php rewrite target needs a prepended leading slash, like /$1.php...