common problem, complicated me.
here requirements trying meet:
- the root url http://example.com should redirected http://www.example.com
- all urls http://example.com/c/1234567890 should redirected http://www.example.com/c/1234567890 (notice "c" fake subdirectory)
- when entered http://example.com/index.php 1 should redirected http://www.example.com (no trailing slashes)
- on top of i'm trying failing secure subfolder "xy" direct access exept php files in root , javascript files.
i searched lot , tried lot of rewrite conditions , rules, htaccess+regex planet me. :/ sorry if duplicate…
these in htaccess file in document root. turn on rewrite engine
rewriteengine on
for 1 , 2: redirect "www" if root request or request /c/(something)
rewritecond %{http_host} ^example\.com$ [nc] rewriterule ^(c/.+)?$ http://www.example.com%{request_uri} [l,r=301]
for 3: redirect direct requests /index.php
/
rewritecond %{the_request} ^[a-z]{3,9}\ /index\.php rewriterule ^ / [l,r=301]
for 4: forbid direct access in /xy/
directory.
rewritecond %{http_referer} !http://(www\.)?example\.com/ [nc] rewriterule ^xy/ - [l,f]
Comments
Post a Comment