Proposed .htaccess update

Proposed .htaccess update, a forum discussion on Jojo CMS. Join us for more discussions on Proposed .htaccess update on our Suggestions & Feedback forum.

Back to Forum Index : Back to Suggestions & Feedback   RSS
Rick Rick

19 Feb 2015
Posts: 336

Dropping this in here for review... what do you think?

This automatically handles the RewriteBase so the .htaccess file doesn't need updated if the site is moved to/from a subfolder/root (eg maybe a staging location to live).

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteCond %{REQUEST_URI}::$1 ^(.*?/)(.*)::\2$
RewriteRule ^(.*)$ - [E=BASE:%1]

RewriteRule ^$ index.php?uri= [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ %{ENV:BASE}index.php?uri=$1
</IfModule>
Rick Rick

19 Feb 2015
Posts: 336

We could even change the last line to RewriteRule ^ %{ENV:BASE}index.php [L] and drop the $uri by using a combo of $_SERVER["REQUEST_URI"] and the $_SERVER["BASE"] created by the new rules...

eg
$uri = substr($_SERVER["REQUEST_URI"], strlen($_SERVER["BASE"]));
tom

Developer

tom

23 Feb 2015
Posts: 379

Awesome!
Back to Forum Index : Back to Suggestions & Feedback   RSS
You must be logged in to post a reply



You need to Register or Log In before posting on these forums.