Help with basic .htaccess mod_rewrite

I am currently interpreting wild-cards subdomains with php, and I would like to process them using .htaccess, user profiles will be accessed at http://username.mysite.com/ (or for some http: // www. username.mysite.com/ ) which should use /main.php?action=profile

The hardest part of this is to make the message / error / i + am + a + test + or /files/iamatestfile.jpg go to & error = i + am + a + test + message or / amp; files = iamatestfile.jpg

Thanks for any help!

0
source share
2 answers

Try:

 RewriteRule ^error/(.*) index.php?error=$1 [L]
 RewriteRule ^file/(.*) index.php?file=$1 [L]

... for the last two.

+2

:

# stop rewriting for the host names example.com and www.example.com
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteRule ^ - [L]

RewriteRule ^error/(.*) index.php?error=$1 [L]
RewriteRule ^file/(.*) index.php?file=$1 [L]
0

Source: https://habr.com/ru/post/1709121/


All Articles