Forum Moderators: phranque
There are 2 level of subdirectories dir1/dir2
The problem is when i use mod rewrite dir1/dir2/dir1 is also valid and show the content of dir1.
This creates an endless amount of subdirectories like ;
games/entertainment/basketball/money/health/webmaster/chat/
which are supposed to be either dir1 or dir 2 level
I should have 4000 indexed pages on google but the current number is 145.000 . And this kills all my rankings..
The htaccess file is something like that :
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteCond %{REQUEST_FILENAME}!-l
RewriteRule ^games(.*) index.php
RewriteRule ^entertainment(.*) index.php
RewriteRule ^money(.*) index.php
Where i am making a mistake? How can i prevent this error?
Thanks...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^games/[^/]+/?$ /index.php [L]
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^entertainment/[^/]+/?$ /index.php [L]
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^money/[^/]+/?$ /index.php [L]
However, you might ask yourself the question, "Do I have any URLs in the form "/dir1/dir2" that I *do not* wish to rewrite to index.php? If so, how many are there?
If the answer is "no", or if there are only a few URLs of that form that you don't want to rewrite, then you can dispense with the multiple RewriteConds and RewriteRules, and just use one rule:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^[^/]+/[^/]+/?$ /index.php [L]
RewriteRule ^d/[^/]+/[^/]+/?$ /index.php [L]
Jim
However, you might ask yourself the question, "Do I have any URLs in the form "/dir1/dir2" that I *do not* wish to rewrite to index.php? If so, how many are there?
I had a few real directories so my case was the first one you suggested.. I had to write a rule for each directory but afterall its working perfect..
I have been looking for a solution for a couple of weeks and i cant really tell how grateful i am...
RewriteCond $1 !^admin/stats
RewriteCond $1 !^cart/scripts
RewriteRule ^([^/]+/[^/]+)/?$ /index.php [L]
You could also avoid multiple rules for your current method like this:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(games¦entertainment¦money)/[^/]+/?$ /index.php [L]
Replace the broken pipe "¦" characters above with solid pipe characters before use; Posting on this forum modifies the pipe characters.
Jim
[edited by: jdMorgan at 11:21 pm (utc) on Sep. 16, 2007]