0

We have a a site that has a url like such:

http://www.example.com/sample

Internally on the server the directory structure is like this:

/site-specific/www.example.com/sample

The htaccess looks like this:

RewriteCond %{REQUEST_URI} ^/sample/(.*)$
RewriteRule ^(.*)$ /site-specific/%{HTTP_HOST}/sample

If I visit http://www.example.com/site-specific/www.example.com/sample I can get to the content. But visiting www.example.com/sample leads to a 404.

Any ideas?

  • 1
    I am not sure why you are doing this? This does not make sense to me. Your path /site-specific/www.example.com should not enter the picture at all that I can see. Without telling us the same thing, can you tell us the problem you are trying to solve?? What started you on this path? – closetnoc Sep 14 '15 at 21:26
1

You can't access /sample because your pattern is expecting /sample/ (with a trailing slash).

However, if you simply want to rewrite from one URL to the other, then all you need is:

RewriteRule ^(sample)$ /site-specific/%{HTTP_HOST}/$1 [L]

The captured groups (ie. (.*)) in your original code would seem to be unnecessary. (?) The captured group above and the $1 is simply to avoid you having to retype "sample" in the substitution.

  • The entirety of the rule is from when it was hosted on another site. We switched hosts and changes directory structure a bit. I'll try your answer first thing in the morning. Thanks! – StevenPatz Sep 14 '15 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.