Skip to main content
Inspiring
May 14, 2008
Answered

CF and .htaccess Help!!!

  • May 14, 2008
  • 1 reply
  • 512 views
I need help in creating a dynamic .htaccess file... I currently have the following set up and it works great...

RewriteEngine on
RewriteRule ^([^/]*)\.html$ http://www.mysite.com/mydir/thepage.cfm?pagename_id=$1

So if you were to go to www.mysite.com/mydir/hello-world.html it will work perfectly

-------------------------------------------

Here is the situation though....

1. I need to create a dynamic .htaccess file because multiple sites are going to be sharing the same "webfiles" on the server.

For instance:

mysite.com will access files "a"
yoursite.com will access files "a" also.


So the issue here is that if my .htaccess file has http://www.mysite.com hardcoded into the file, then if yoursite.com tries to access the "a" files, then it will automatically redirect to mysite.com

How do I create a .htaccess file that will interpret what the web site is and automatically change the .htaccess...

For instance:

mysite.com .htaccess will be

RewriteEngine on
RewriteRule ^([^/]*)\.html$ http://www.mysite.com/mydir/thepage.cfm?pagename_id=$1

and yoursite.com .htaccess will be

RewriteEngine on
RewriteRule ^([^/]*)\.html$ http://www.yoursitecom/mydir/thepage.cfm?pagename_id=$1

Is there anyway to make this part (the ???????) dynamic: http://www.?????????.com/mydir/thepage.cfm?pagename_id=$1

Anyones help on this would be greatly appreciated!!!!!!
This topic has been closed for replies.
Correct answer bweno
Thanks. That worked perfectly... Must have lost my mind for a few :)

1 reply

Participating Frequently
May 15, 2008
why do you need the domain name in the rewrite rule at all? what's wrong with...or does the mydir bit change per domain?

RewriteEngine on
RewriteRule ^([^/]*)\.html$ /mydir/thepage.cfm?pagename_id=$1
bwenoAuthorCorrect answer
Inspiring
May 15, 2008
Thanks. That worked perfectly... Must have lost my mind for a few :)