Answer the question
In order to leave comments, you need to log in
How to properly configure .htaccess for a task?
Comrades, I ask for your help.
What we have:
a slash at the end is required: domain.ru/test -> redirected to test/
the actual string test (maybe two words through a dash, there may be numbers) was given to index.php?page=$1
while js css was loaded from of their folders
, any img/image name request went away getphoto.php?src=image name
any upload/folder/image name request went away as well getphoto.php?folder=&src=
there is also an admin folder, it should work normally.
I ideally want any request other than images or statics to go to index.php?page=
I did this:
RewriteCond %{REQUEST_URI} ^/.*
RewriteRule ^ajax$ /admin/ajax.php [L]
RewriteRule ^sitemap.xml$ sitemap.xml [L]
RewriteRule ^admin/(.*)$ admin/$1 [L]
RewriteRule ^.*css/(.*)$ css/$1 [L]
RewriteRule ^.*fonts/(.*)$ fonts/$1 [L]
RewriteRule ^.*js/(.*)$ js/$1 [L]
RewriteRule ^.*img/(.*)$ getphoto.php?src=$1 [L]
RewriteCond %{REQUEST_URI} /$ [NC]
RewriteRule ^.*img/(.*)(/)$ getphoto.php?src=$1 [L]
#RewriteCond %{REQUEST_URI} !^/uploads/.*$ [NC]
#RewriteRule ^(.*)$ getphoto.php?src=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*[^/])$ $1/ [L,R=301]
RewriteRule ^(.*)(/)$ index.php?src=$1 [QSA,L]
Answer the question
In order to leave comments, you need to log in
RewriteRule ^sitemap.xml$ sitemap.xml [L]
RewriteRule ^admin/(.*)$ admin/$1 [L]
RewriteRule ^uploads/([^/]+)/(.*)$ getphoto.php?folder=$1&src=$2 [L]
RewriteRule (js|css|fonts)/(.*) $1/$2 [L]
RewriteRule img/(.*)$ getphoto.php?src=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/.]+)$ /$1/ [L,R=301]
RewriteRule ^(.*)/$ index.php?src=$1 [QSA,L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question