.htaccess

྅༻ Ǭɀħ ༄༆ཉ edited this page Aug 14, 2014 · 11 revisions

What your .htaccess file for YOURLS should look like

Make a .htaccess file

If .htaccess file creation/updating failed because of file permission, you'll have to manually make one. No worry, it's simple.

Note: YOURLS also works with IIS and nginx

Note: as stated in various places such as the readme, YOURLS cannot share its root directory with another .htaccess rewrite rules driven app such as WordPress. The .htaccess file should contain YOURLS directives and no other rewrite rule.

Case: YOURLS installed on root

If YOURLS root URL is http://yoursite/, the .htaccess file in the root directory must be like:

# BEGIN YOURLS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /yourls-loader.php [L]
</IfModule>
# END YOURLS

Case: YOURLS installed in subdirectory

If YOURLS root URL is http://yoursite/somedir/, the .htaccess file in this subdirectory must be like:

# BEGIN YOURLS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /somedir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /somedir/yourls-loader.php [L]
</IfModule>
# END YOURLS

Bonus tricks

We have some bonus tricks for your .htaccess file that may suit your needs or improve your overall experience.