Gossamer Forum
Home : Products : Gossamer Links : Discussions :

mod_rewrite question

Quote Reply
mod_rewrite question
hi,



does anyone know how a complete mod_rewrite-.htaccess file should look like if I want to do the following:



+ I have my LSQL-index.html at http://www.mydomain.de/index.html (root-directory)

+ the domain http://www.mydomain.com points to exactly the same index.html (root-directory)

What I want is a rewrite-rule if someone uses the .com-domain (http://www.mydomain.com) so that this is rewritten to:

http://www.mydomain.com/...1&t=com_template

(rewriting/redirecting static .com-URL to dynamic .com-page.cgi-index.html+template)



Cheers,

Manu

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] mod_rewrite question In reply to
Hi,

I've been using this rewrite rule:

RewriteEngine On
RewriteRule ^/$ http://server.com/...n/Links/page.cgi?d=1 [R,L,NC]

The problem with that, was it didn't tickle google very well.

I changed that, to using a directory index:

<directory /www/betterbeads/public>
DirectoryIndex /cgi-bin/Links/page.cgi?d=1
</directory>


And it changed the google ranking significantly.

In your case, you want to screen out the .com, and rewrite it. I did something similar when I have a .com pointing to one section, and a .org pointing to another section:

RewriteCond %{HTTP_HOST} ^.*domain.com [NC]
RewriteRule ^/$ http://domain.com/...1&t-com_template [R,L,NC]

The rewrite condition will only apply if people type a .com domain, and then the rule will kick in and rewrite the ROOT request (start and end with a "/") to the new URL.

This *worked* and *works* on my site, the "R" is necessary to do a full redirect, or things don't quite work. Alex had suggested a different solution, but it generated server errors.

This should get you started ;)

Check the http://apache.org docs for some help with rewrite rules. My links were stolen with the computer, but a bit of searching will find a few good pages with examples, and suggestions.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] mod_rewrite question In reply to
hi pugdog,

thanks very much. I'll look at it on monday.

I'm not quite sure if this really works for me, because everything is absolutely identical for my .de and .com domains (server paths, directories, etc.) .

For my .de-domain I'm using both, static and dynamic-mode with my default template.

At the moment my .com-domain uses exactly this too (so it doesn't matter if you use .com or .de-URLs, you always get the same pages).

What I want is, if someone uses the .com-URL the server is forced to use LSQL_dynamic-mode with another template...

As I said, I'll have a closer look at it on monday.

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
Quote Reply
Re: [ManuGermany] mod_rewrite question In reply to
Couldn't you use virtualhost - something like this (change ip from 222.222.222.222 to your ip, template to name of your template and domain.com to your domain). Also it is useful to have errors within the template set - you can do this for all your error documents by creating template pages for error404.html error500.html etc. This also assumes that your links are in a directory called links.

<VirtualHost 222.222.222.222>
ServerName www.domain.com
ServerAdmin admin
DocumentRoot /path/to/web
ServerAlias domain.com www.domain.com
RewriteEngine on
RewriteCond %{HTTP_HOST} !^222.222.222.222(:80)?$
RewriteCond %{HTTP_HOST} !^www.domain.com(:80)?$
RewriteRule ^/(.*) http://www.domain.com/$1 [L,R]
RewriteRule ^/$ /cgi-bin/page.cgi?t=template [PT]
RewriteRule ^/links/(.*)$ /cgi-bin/page.cgi?t=template&p=$1 [PT]
ErrorDocument 404 /cgi-bin/page.cgi?p=error404&t=template
</VirtualHost>