1
1
16Gb2018-02-28 16:54:05
htaccess
16Gb, 2018-02-28 16:54:05

How to make a redirect with htaccess with get parameters?

I'm trying to redirect from 1 link to the second, but the site doesn't even respond
/forum/46-24786-1
/forum/index.php?threads/46/24786/page-1
RewriteRule ^forum/([^&]+)- ([^&]+)-([^&]+)$ /forum/index.php?threads/%1/%2/page-%3 [L,R=301]
Here is my attempt

Answer the question

In order to leave comments, you need to log in

2 answer(s)
1
16Gb, 2018-02-28
@16Gb

/forum/46-24786-1
/forum/index.php?threads/46/24786/page-1
46 this is section
number 24786 thread number
1 page number
i just wanted to pass these parameters
it doesn't work, no redirect occurs
RewriteRule ^forum /([^&]+)-([^&]+)-([^&]+)$ /forum/index.php\?threads/$1/$2/page-$3 [L,R=301]
if insert
RewriteCond %{REQUEST_URI} forum/([^&]+)-([^&]+)-([^&]+)
RewriteRule forum .*$ /forum/index.php?threads/%1/%2 /page-%3
then error 500
at ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 405 default
ErrorDocument 406 default
ErrorDocument 500 default
ErrorDocument 501 default
ErrorDocument 503 default
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(data /|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
here is my entire htaccess
RewriteRule ^forum/46-24786-1$ /forum/index.php?threads/46/24786/page-1 [L,R=301]
even such a direct line without parameters does not work
DONE THIS
RedirectMatch 301 ^/forum/(\d *)-(\d*)-(\d*)$ /forum/index.php?threads/$1/$2/page-$3

V
Viktor Taran, 2018-02-28
@shambler81

this is how a redirect from a get parameter to a regular url would look like.

# 301 --- http://www.mydefile.ru/lookbook/?type=Лукбуки&PAGEN_1=2 => http://www.mydefile.ru/news/lookbooks/
RewriteCond %{QUERY_STRING} (^|&)type=Лукбуки($|&)
RewriteCond %{QUERY_STRING} (^|&)PAGEN_1=2($|&)
RewriteRule ^lookbook/$ /news/lookbooks/? [L,R=301]

In your case, on the contrary, it is still much simpler here, you just mixed up %and$
And don't forget to escape the question
And the percentages are done like this
RewriteCond %{REQUEST_URI}  forum/([^&]+)-([^&]+)-([^&]+)
RewriteRule forum .*$ /forum/index.php?threads/%1/%2/page-%3

You can also combine them with parentheses from the rule and then the conda
will be like this
. Now, regarding the regular season, something is very strange with you. what exactly does she do in your opinion?
Throw off a couple of urls that she should highlight

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question