Answer the question
In order to leave comments, you need to log in
How to make redirect get page request to main page except some pages?
There is such a structure:
- Main (index.php)
- Login page (signin.php)
- Registration page (signup.php) -
User
page (user.php)
- User admin panel (admin.php)
It works like this:
the main page is authorized and a session is created (if there is a session, it redirects to admin.php)
For each user, the user.php page takes the get parameter login. Thus, if you go to site.ru/user.php?login=user1, we will see user1's data from the database.
I want to convert the complex structure site.ru/user.php?login=user1 into site.ru/user1
I write the following in the .htaccess file:
RewriteEngine on
RewriteRule ^(.*)$ user.php?login=$1 [L]
RewriteEngine on
RewriteRule ^m/(.*)$ user.php?login=$1 [L]
Answer the question
In order to leave comments, you need to log in
GET is not part of the url and does not go to the rewrite rule.
To select it, we use a two-level construct
. Also, everything that is $1 from the conda will be %1
# 301 --- www.test.com/faq.html?faq=13&layout=bob => www.test2.com/faqs.html
If host such and such
AND if there is a get request such and such
AND THERE IS NO such and such a request Exception is !
RewriteCond %{QUERY_STRING} !(^|&)layout\=bob2($|&)
THEN execute such a rule
Such a construction is optional. (^|&)faq\=13($|&)
It can be reduced to faq \= 13, but the constitution itself chose the option with and without an upmersant.
Also pay attention to the end of the wheel itself, that at the end it stands ?
in such a spelling will remove the get parameters altogether
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question