V
V
vsevolod08122014-08-02 01:02:02
PHP
vsevolod0812, 2014-08-02 01:02:02

Correctly compose .htaccess?

At the moment I have this .htaccess

AddDefaultCharset UTF-8

ErrorDocument 401 /media/error/401.html
ErrorDocument 403 /media/error/403.html
ErrorDocument 404 /media/error/404.html

RewriteEngine On

RewriteRule ^([_a-zA-Z0-9]+)$ /system/page/profile.php?username=$1 [L,QSA]

The problem is that when you type site.com/media it throws site.com/media/?username=media and media is a folder, you need to make sure that it does not accept folders.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tyranron, 2014-08-02
@vsevolod0812

You can exclude real-life folders and files by adding 2 conditions for the rule:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([_a-zA-Z0-9]+)$ /system/page/profile.php?username=$1 [L,QSA]

W
whats, 2014-08-02
@whats

Where should it be transferred? according to the regular expression, everything is correctly thrown

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question