HOW TO set "mod_rewrite" correctly on temporary hosting?

Discuss everything related to ApPHP Durecty CMF. All versions. Any questions related to the Directy CMF developing or using should be posted to this forum.

Moderators: alexandrleonenko, alexmst

administrator
Site Admin
Site Admin
Posts: 6004
Joined: Jan 7th, '09, 23:18
Contact:

HOW TO set "mod_rewrite" correctly on temporary hosting?

Postby administrator » Nov 18th, '17, 20:41

If you try to run "mod_rewrite" on temporary hosting (without domain name, just IP address) you have to set RewriteBase and RewriteRule values correctly.

When you use a domain name, you simply define following rules in .htaccess file:

Code: Select all

# Rewrite URL rules
<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-l
   
   # Rewrite all other URLs to index.php/URL
   RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>


But if you use IP address on shared hosting (ex.: 123.123.123.123/~username/),
these rules must be defined in following way:

Code: Select all

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteBase /~username
   RewriteRule ^index\.php$ - [L]

   RewriteCond %{REQUEST_FILENAME} !-d
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-l

   # This way
   RewriteRule ^(.*)$ /~username/index.php?url=$1 [QSA,L]   
   # or another option
   # RewriteRule .? /~username/index.php
</IfModule>

Return to “ApPHP Directy CMF {developers/users}”