Mobile app version of vmapp.org
Login or Join
Sims2060225

: Rewrite rule for url that's different than directory structure 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

@Sims2060225

Posted in: #Htaccess

We have a a site that has a url like such:
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 www.example.com/site-specific/www.example.com/sample I can get to the content. But visiting example.com/sample leads to a 404.

Any ideas?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Sims2060225

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ann8826881

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}/ [L]


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

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme