A
A
Alena2018-02-12 20:46:21
htaccess
Alena, 2018-02-12 20:46:21

Which mod rewrite rule should be added?

Hello and please help! There is a site on WP where mod rewrite is enabled. For some reason, I needed to add get parameters at the end of links, so we have domen.ru/contact/office/?type=timetable
Question: what should be done to convert such links to domen.ru/contact/office/timetable
Contents .htaccess is now standard, as VP gives:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

I haven’t come across mod rewrite before, and the task needs to be completed quickly, so I really ask for any help. And, as an addition, can anyone have links to sensible materials on mod rewrite? For self study :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2018-02-13
@shambler81

# 301 --- http://www.mydefile.ru/company/?section=torgovlya&PAGEN_1=9 => http://www.mydefile.ru/about/
RewriteCond %{QUERY_STRING} (^|&)section=torgovlya($|&)
RewriteCond %{QUERY_STRING} (^|&)PAGEN_1=9($|&)
RewriteRule ^company/$ /about/? [L,R=301]

Of these, (^|&)........($|&)this is just an assumption that a get can start both from the beginning and be through &.
if you need to remove get parameters then just add a question mark at the end.
If you need to redirect TO the get parameter, then on some servers you will need to escape the question zak.
RewriteRule . /index.php\?id=22 [L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question