have such kind of error.
When adding Redirect 301 rule to .htaccess file like:
Redirect 301 "/page1.html" "/dir1/"
My site fails with 500 server error and in apache error log this error appears:
[Wed Mar 16 11:08:52 2011] [alert] [client 127.0.0.1] /home/htdocs/site.com/www/.htaccess: Redirect to non-URL
Mod rewrite is installed, also tried to provide urls without quotes.
On production server this .htaccess works fine, but on local causes troubles
Any ideas, please)
This rule works
Redirect 301 "/page1.html" "http://www.site.com/dir1/"
but I need a way to supply relative paths instead of full urls (production server works that way)
asked Mar 16, 2011 at 9:54
Dmitry EvseevDmitry Evseev
11.5k3 gold badges34 silver badges48 bronze badges
Changed all Redirect 301 rules to:
RewriteRule ^/page1.html$ /dir1/page.html [R=301,L]
now working. But how does it work on production?
answered Apr 7, 2011 at 10:31
Dmitry EvseevDmitry Evseev
11.5k3 gold badges34 silver badges48 bronze badges
For me, I had the exact same issue. Adding «http://domain.com» in front of «/mypage» worked; I am still testing to get it to work without, as is does on my production server. So my .htaccess on my local testing environment, went like this:
BROKEN:
Redirect 301 /mypage /directory1/sub-directory/mypage/
FIXED:
Redirect 301 http://mydomain.com/mypage http://mydomain.com/directory1/sub-directory/mypage/
answered Mar 24, 2011 at 23:32
1
I had same issue, for me this didn’t work as well:
RewriteRule ^/page1.html$ /dir1/page.html [R=301,L]
What worked for me is to remove the leading slash, and add soft tailing slash with ?, like this:
RewriteRule ^(page1.html)/?$ dir1/page.html [R=301,L]
answered May 31, 2016 at 10:31
Maor BarazanyMaor Barazany
7612 gold badges11 silver badges21 bronze badges
Please try this, it’s working as expected.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
Redirect 301 /our_clients/nike /project/nike-nofyme-campaigns
</IfModule>
answered Dec 19, 2019 at 12:15
have such kind of error.
When adding Redirect 301 rule to .htaccess file like:
Redirect 301 "/page1.html" "/dir1/"
My site fails with 500 server error and in apache error log this error appears:
[Wed Mar 16 11:08:52 2011] [alert] [client 127.0.0.1] /home/htdocs/site.com/www/.htaccess: Redirect to non-URL
Mod rewrite is installed, also tried to provide urls without quotes.
On production server this .htaccess works fine, but on local causes troubles
Any ideas, please)
This rule works
Redirect 301 "/page1.html" "http://www.site.com/dir1/"
but I need a way to supply relative paths instead of full urls (production server works that way)
asked Mar 16, 2011 at 9:54
Dmitry EvseevDmitry Evseev
11.5k3 gold badges34 silver badges48 bronze badges
Changed all Redirect 301 rules to:
RewriteRule ^/page1.html$ /dir1/page.html [R=301,L]
now working. But how does it work on production?
answered Apr 7, 2011 at 10:31
Dmitry EvseevDmitry Evseev
11.5k3 gold badges34 silver badges48 bronze badges
For me, I had the exact same issue. Adding «http://domain.com» in front of «/mypage» worked; I am still testing to get it to work without, as is does on my production server. So my .htaccess on my local testing environment, went like this:
BROKEN:
Redirect 301 /mypage /directory1/sub-directory/mypage/
FIXED:
Redirect 301 http://mydomain.com/mypage http://mydomain.com/directory1/sub-directory/mypage/
answered Mar 24, 2011 at 23:32
1
I had same issue, for me this didn’t work as well:
RewriteRule ^/page1.html$ /dir1/page.html [R=301,L]
What worked for me is to remove the leading slash, and add soft tailing slash with ?, like this:
RewriteRule ^(page1.html)/?$ dir1/page.html [R=301,L]
answered May 31, 2016 at 10:31
Maor BarazanyMaor Barazany
7612 gold badges11 silver badges21 bronze badges
Please try this, it’s working as expected.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
Redirect 301 /our_clients/nike /project/nike-nofyme-campaigns
</IfModule>
answered Dec 19, 2019 at 12:15
Redirect 301 keyboardchart.php keyboard-chart.php
The 500 error is because the target URL is relative. That is not allowed with a mod_alias Redirect. The target URL must either be absolute (with a scheme and hostname) or must start with a slash (ie. root-relative).
But also, the source URL-path will not match either. You must specify a root-relative URL-path, starting with a slash.
Regardless of where the .htaccess file is located, the mod_alias Redirect directive is the same. Unlike mod_rewrite (RewriteRule) that has the concept of a «directory-prefix».
So, like VladShundalov suggests, you would need a directive of the form:
Redirect 301 /keyboard/keyboardchart.php /keyboard/keyboard-chart.php
Note that this matches any query string. The query string is automatically passed through to the target. You can’t actually match the query string with a mod_alias Redirect.
If you need to match the specific query string then you must use mod_rewrite instead. For example, in the example.com/keyboard/.htaccess file you could write something like:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^gam=7&sty=15&lay=1$
RewriteRule ^keyboardchart\.php$ /keyboard/keyboard-chart.php [R=301,L]
Note that you don’t state the subdirectory on the RewriteRule pattern in this case, however, you do still need a root-relative path on the substitution (unless you specify the path with a RewriteBase directive). The query string is passed through to the substitution automatically by default.
I’ve added individual 301 redirect entries to .htaccess to redirect my old site’s Mambo pages to the new site’s Joomla pages, but the old URLs still generate 404 errors. Any ideas why? The format I used was:
Redirect 301 http://www.site.com/old.htm http://www.site.com/new.htm
I added these at the end of the .htaccess file.
asked Apr 10, 2011 at 4:18
The Redirect directive doesn’t take a full URL as the «old» location.
Try:
Redirect 301 /old.htm http://www.site.com/new.htm
From the documentation:
The old URL-path is a case-sensitive
(%-decoded) path beginning with a
slash. A relative path is not allowed.
The new URL should be an absolute URL
beginning with a scheme and hostname,
but a URL-path beginning with a slash
may also be used, in which case the
scheme and hostname of the current
server will be added.
answered Apr 10, 2011 at 5:12
Shane MaddenShane Madden
115k13 gold badges181 silver badges251 bronze badges
0
You must log in to answer this question.
Not the answer you’re looking for? Browse other questions tagged
.
Not the answer you’re looking for? Browse other questions tagged
.
0 Пользователей и 1 Гость просматривают эту тему.
- 3 Ответов
- 1575 Просмотров
Здравствуйте!
При добавлении редиректа 301 со старого URL на новый в файл htaccess происходит крах сайта с ошибкой 500.
Что примечательно — если удалить из файла htaccess добавленные строки, сайт все равно не восстанавливается и продолжает выдавать ошибку 500. Помогает только восстановление файла из бэкапа.
Строка редиректа такая:
Redirect 301 /category/tovari-dlya-doma http://site.ru/tovari-dlya-doma
Файл htaccess такой:
Есть какие-то идеи?
удалить из файла htaccess добавленные строки, сайт все равно не восстанавливается
Скорее всего, просто кеш браузера надо почистить было. у меня в Chrome так всегда с htaccess.
Скорее всего, просто кеш браузера надо почистить было. у меня в Chrome так всегда с htaccess.
так и есть. безусловный редирект вида
Redirect 301 /category/tovari-dlya-doma http://site.ru/tovari-dlya-doma
браузеры кешируют. на время тестов проверяйте ответ сервера любым онлайн сервисом. в Google их полно, так и гуглите «проверить ответ сервера». указываете свой url и смотрите на результат, как переадресовывает, какой ответ и т.д.
Записан
Тут дарят бакс просто за регистрацию! Успей получить!
Все советы на форуме раздаю бесплатно, то есть даром. Индивидуально бесплатно консультирую только по вопросам стоимости индивидуальных консультаций
удалить из файла htaccess добавленные строки, сайт все равно не восстанавливается
Скорее всего, просто кеш браузера надо почистить было. у меня в Chrome так всегда с htaccess.
так и есть. безусловный редирект вида
Redirect 301 /category/tovari-dlya-doma http://site.ru/tovari-dlya-domaбраузеры кешируют. на время тестов проверяйте ответ сервера любым онлайн сервисом. в Google их полно, так и гуглите «проверить ответ сервера». указываете свой url и смотрите на результат, как переадресовывает, какой ответ и т.д.
кэш не причем. Ломался весь сайт после редактирования файла htaccess. В процессе выяснилось что такая реакция на любое изменение файла происходит. Я просто одну точку в информационном тексте внутри файла добавлял и сайт сразу ломался — выдавал ошибку 500.
Причина оказалась банальной — хостинг что-то там настроил, что редактирование файла htaccess через браузер приводило к таким последствиям. Я скачал файл на комп, внес необходимые изменения, закачал на хостинг, и все работает.
Раньше спокойно редактировал через браузер.

