mod_rewrite URL and SEO

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I was searching answer for ma question everywhere but I couldn't find
it, so please HELP ME.

I have a hosted server. I have one main domain. There is some website
under this domain. i'm using mod_rewrite to have SEO URL's so insted I have All
mod_rewrite rules are in .htaccess file.

Using cPanel I've created subdomain There is a
different website under this domain, but i want to have also SEO URL's,
( goes to so
I added this code to .htaccess file in main directory:


RewriteCond % !^www\.sub\.domain\.com$
RewriteCond % ^(.*)sub\.domain\.com$
RewriteRule ^site/([0-9]+)$ =$1

but this code doesn't work. Please help me, what's wrong whith this

Thanks in advance,


Re: mod_rewrite URL and SEO wrote:
Quoted text here. Click to load it

If HTTP_HOST is *not*

Quoted text here. Click to load it

AND HTTP_HOST *ends* with

Quoted text here. Click to load it

With this rule, you should expect to see requests like:

All be redirected (because of the complete URL) to:

Therefore, the browser's location bar should change...

Quoted text here. Click to load it

What exactly isn't working - or maybe I should ask what is happening?

Justin Koivisto, ZCE -

Re: mod_rewrite URL and SEO

I get lost.

I'd be grateful for help.

I only want two rules for my subdomain:

RewriteRule ^site/([0-9]+),([0-9]+)$ index.php?section=$1&article=$2
RewriteRule ^site/([0-9]+)$ index.php?section=$1 [L]

first is for displaying articles, second for displaying section

index.php file is in subdomain.

so my code should look like this:


RewriteCond % ^sub\.domain\.com [NC]
RewriteRule ^site/([0-9]+),([0-9]+)$ =$1&article=$2 [L]

RewriteCond % ^sub\.domain\.com [NC]
RewriteRule ^site/([0-9]+)$ =$1

but when I request: I get message

The requested URL /site/39 was not found on this server.

So please, help me, how to write code to make it work

Best regards


sorry for multiposting but I'm desperate ;(

Re: mod_rewrite URL and SEO

F'up to: alt.apache.configuration

barcin wrote:
Quoted text here. Click to load it

Is the DocumentRoot of the same as

In the .htaccess file try something like this (untested):

RewriteCond % (.*)\.sub\.domain\.com
RewriteRule ^site/([0-9]+)(,([0-9]+))?$ index.php?section=$1&article=$3

Also, be sure that this rule is above any similar rules in the file that
do not use the RewriteCond statement for it's domain...

Justin Koivisto, ZCE -

Site Timeline