L
L
La2ha2013-10-25 09:17:40
PHP
La2ha, 2013-10-25 09:17:40

What's wrong with RewriteRule (internal redirect not working)

The site has a page with the address

/car_sets/search?search_category=car_sets&category=auto&make=BMW

Seoshniki asked for this page to make a copy with the address:
/mashinokomplekt-bmw


It is not very convenient to do this using php (Laravel framework), I decided to make an internal redirect using htaccess
But the internal redirect does not work for some reason (404 error pops up), here is my entire htaccess
<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On
    RewriteBase /
</IfModule>


<IfModule mod_rewrite.c>
#Запрет на просмотр директорий
    Options All -Indexes
#редирект с www на без www
    RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
#редирект с index.php на без
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
    RewriteRule ^index\.php$ / [R=301,L]
#убираем последний слэш
    RewriteRule ^(.*)/$ $1 [R=301,L]


    RewriteRule ^mashinokomplekt-bmw? car_sets/search?search_category=car_sets&category=auto&make=BMW [L]


    #условие, что все существующие папки не будут обрабатываться регулярным выражением
  RewriteCond %{REQUEST_FILENAME} !-f
  #условие, что все существующие файлы не будут обрабатываться регулярным выражением
  RewriteCond %{REQUEST_FILENAME} !-d
  #регулярное выражение, в нашем случае — при любой строке запроса будет открывать index.php,
  RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

AddDefaultCharset UTF-8
php_value max_execution_time 0

If you make the redirect external
RewriteRule ^mashinokomplekt-bmw? car_sets/search?search_category=car_sets&category=auto&make=BMW [R=301,L]

That redirects, but the task is to make an internal redirect

PS.
If I do an internal redirect not for the site. And for some test.php it works as it should.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
tvolf, 2013-10-25
@tvolf

If you have access to the host settings, then you can try to enable logging for mod_rewrite. There are two different options for two branches of Apache, as I understand it. Well, from the logs it will already be easier to understand how a particular url is processed.

R
rakeev, 2013-10-25
@rakeev

Seems like a very logical behavior to me. You told me not to do anything else after hitting mashinokomplekt-bmw [L]. So he honestly tries to search for the car_sets / search.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question