Denes Papp
Denes Papp

Reputation: 3982

How to use mod_rewrite in a subdomain's .htaccess?

I have a domain (let the name be) mydomain.com. I added a subdomain, sub.mydomain.com. (It's an other site, the two sites don't have anything to do with each other)

I have mapped the subdomain (with godaddy.com's tool) to /sub directory. It works well with static file paths, ex. http://sub.mydomain.com/js/script.js.php. However, I would like to be able to use the rewrite module to get http://sub.mydomain.com/js/script.js

My .htaccess files:

.htaccess in the root directory:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub.mydomain.com$
RewriteRule ^.*$ http://mydomain.com/sub%{REQUEST_URI} [L,P]

.htaccess in the /sub directory:

RewriteEngine on
RewriteRule ^js/script\.js$ js/script.js.php [L]

(I tried adding RewriteBase /sub/, I didn't succeed). It seems as if Apache didn't notice the /sub's .htaccess

How can I get the rewrite work on the subdomain's paths?

Upvotes: 0

Views: 1327

Answers (1)

Denes Papp
Denes Papp

Reputation: 3982

SOLVED!

After a long, exhausting debugging and googling I found an Apache setting that made the trouble:

I added Options -MultiViews and voilá, it works!

/////////////////////////////////////////////

Now my configuration:

-no .htaccess in the root.

-.htaccess in the root/sub:

DirectoryIndex site/index.php
Options -MultiViews
RewriteEngine on
RewriteRule ^site/js/script.js$ /site/js/script.js.php [L]

Upvotes: 1

Related Questions