Martyn
Martyn

Reputation: 6403

Mod rewrite rule not being applied

I'm changing the URL to one of my web apps (questions). Previously it was of the URL: questions.myproject.com; but I want to change this to: myproject.com/questions so that the old URL is still supported.

Below is what I'm putting in /public/.htaccess:

#dev
RewriteCond %{HTTP_HOST} ^questions\.local-japantravel\/questions
RewriteRule ^/(.*) http://local-japantravel/questions/$1 [L,R]

I tested this with the URL http://questions.local-japantravel/questions/css/all.css (as this is what the old path no tries to access paths like "/questions/css/all.css" which the app now assumes at the new URL) but no joy. I've tried this on an online htaccess tester too - http://htaccess.madewithlove.be/ - but it doesn't apply the rule

I can also confirm that mod rewrites are on.

Is there anything I'm doing wrong there?

Upvotes: 1

Views: 110

Answers (2)

anubhava
anubhava

Reputation: 786289

You can use this rule in the root .htaccess of question subdomain:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^questions\.(local-japantravel)$ [NC]
RewriteRule ^questions(/.*)?$ http://%1%{REQUEST_URI} [NC,L,NE,R=302]

Upvotes: 1

Amit Verma
Amit Verma

Reputation: 41249

Try like this :

RewriteEngine on
RewriteCond %{HTTP_HOST} ^questions\. [NC]
RewriteRule ^/?(.*)/?$ http://local-japantravel/questions/$1 [L,R,NC]

Upvotes: 1

Related Questions