Я хочу перенаправить старый URL-адрес «подробнее» на «подробности» в Apache.Apache

Ответить
Anonymous
 Я хочу перенаправить старый URL-адрес «подробнее» на «подробности» в Apache.

Сообщение Anonymous »

Я хочу перенаправить или переписать старый URL-адрес «подробнее» на «подробнее» в Apache. Файл, о котором идет речь, находится в корне пользователя Apache. Я использую URL-адреса без расширений. Я использую .htaccess. Как мне это сделать?
Я пробовал много регулярных выражений с помощью mod_rewrite и пробовал использовать mod_alias (это правильно). Иногда у меня возникает ошибка 500, иначе перенаправление не происходит, и я просто получаю ошибку 404.
Поскольку все попытки сделать это с помощью .htaccess терпели неудачу, в настоящее время я иметь различные символические ссылки в файловой системе. Поэтому, если вы попробуете URL-адреса, заканчивающиеся на «/more» или «/more.htm», все будет хорошо, создайте впечатление, что за это может быть ответственен .htaccess.
Вот текущий .htaccess (для https://www.skyeshepherdhuts.co.uk):

Код: Выделить всё

##
## Adjusted for the website’s production phase, publicly visible
## ==============================================================
##

RewriteEngine On

# disable directory browsing
Options All -Indexes

## ###################
## Forbid access to .htaccess by browser, now produces a 403 Forbidden error; n.b. useful for testing 403)
##

order allow,deny
deny from all


Header add Content-Security-Policy "default-src 'self';"
Header set Content-Language en-GB

##
## Extensionless URLs technology; if requested no-ext file does not exist,
## and is not a directory and is not already .htm, then rewrite no-ext to .htm
##
##RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !\.htm$
RewriteRule ^(.*)$ $1.htm

AddDefaultCharset utf-8
AddCharset utf-8 .css .js .xml .xhtml .html .xhtm .htm .txt
AddLanguage en-GB .htm .xhtml .html .xhtm .txt

AddType text/css                .css
AddType application/javascript  .js
AddType application/xhtml+xml   .xhtml .html .xhtm .htm
AddType application/xml         .xml
AddType application/manifest+json  .webmanifest .manifest .sitemanifest
AddType text/plain      .txt
AddType image/svg+xml   .svg
AddType image/jpeg      .jpg .jpeg
AddType image/png       .png
AddType image/webp      .webp
AddType image/x-icon    .ico
AddType font/ttf        .ttf

ExpiresActive On
ExpiresDefault                      A3600
ExpiresByType image/jpeg            A2592000
ExpiresByType image/png             A2592000
ExpiresByType image/apng            A2592000
ExpiresByType image/webp            A2592000
ExpiresByType image/svg+xml         A2592000
ExpiresByType image/x-icon          A2592000
ExpiresByType font/ttf              A2592000
ExpiresByType application/manifest+json     A2592000
ExpiresByType application/javascript        A2592000
##
## Shorter suggested cache lifetime for file types more likely to change, in case we should do edits
##
ExpiresByType text/css                  A432000
ExpiresByType application/xhtml+xml     A432000
ExpiresByType text/plain                A1200
ExpiresByType application/xml           A1200

####################
# GZIP COMPRESSION #
####################
SetOutputFilter DEFLATE
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml image/svg+xml application/xhtml+xml application/xml application/javascript application/x-javascript application/x-httpd-php font/ttf application/manifest+json
BrowserMatch ^Mozilla/4         gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678]     no-gzip
BrowserMatch \bMSIE             !no-gzip !gzip-only-text/html
BrowserMatch \bMSI[E]           !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|webp|ttf)$ no-gzip

### declare the error documents’ names
ErrorDocument 404 "/404"
ErrorDocument 403 "/403"

#########
### Declare the start page
#########
# Uses a level of indirection via "_" in order to avoid having to mention the start page name twice

RewriteRule ^/$     _
RewriteRule ^$      _
RewriteRule ^_$     welcome
— [конец .htaccess]
Обратите внимание, что / в https://www.skyeshepherdhuts.co.uk/ переписано на «добро пожаловать " (в / ). Любой URL-адрес без расширения, например «foo», перезаписывается в «foo.htm». Таким образом, https://www.skyeshepherdhuts.co.uk/welcome перезаписывается на https://www.skyeshepherdhuts.co.uk/welcome.htm

Подробнее здесь: https://stackoverflow.com/questions/793 ... -in-apache
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Apache»