2

Im at least 24 hours busy on this subject, I cant seem to get this script to work. The script doesnt redirect at all.

RewriteEngine On RewriteCond %{HTTP_HOST} ^m\.skynet\.com$ RewriteRule ^/(.*)$ /mobile/final/$1 [L,NC] 

What am I doing wrong?

UPDATE:

RewriteEngine On RewriteCond %{HTTP_HOST} ^m\.skynet\.com$ RewriteCond %{REQUEST_URI} !^/mobile/final/ RewriteRule ^(.*)$ /mobile/final/$1 [L,NC] 

This partially works, but links like m.skynet.com\download.php wont get redirected

UPDATE: 45min later

Now it suddenly works. But the URL gets rewritten in FireFox, while in Chrome it works properly

UPDATE Seems that the problem with Firefox was caused by a 301-redirect I used earlier, the cache had to be flushed. for it to work properly again

1 Answer 1

1

Remove leading slash from match:

RewriteEngine On RewriteCond %{HTTP_HOST} ^m\.skynet\.com$ RewriteCond %{REQUEST_URI} !^/mobile/final/ RewriteRule ^(.*)$ /mobile/final/$1 [L,NC] 
  • .htaccess is per directory directive and Apache strips the current directory path (thus leading slash) from RewriteRule URI pattern.
  • You need RewriteCond %{REQUEST_URI} !^/mobile/final/ to prevent looping.
Sign up to request clarification or add additional context in comments.

2 Comments

Seems your solution worked partially, when I enter for example: m.skynet.com/download.php I dont get redirecte to the page in the directory
Not sure what is special about /download.php but this rule will rewrite that to /mobile/final/download.php

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.