Answer the question
In order to leave comments, you need to log in
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
/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
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]
%
and$
RewriteCond %{REQUEST_URI} forum/([^&]+)-([^&]+)-([^&]+)
RewriteRule forum .*$ /forum/index.php?threads/%1/%2/page-%3
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question