0

尽管我已经完成了具有相同主题的其他条目,但我无法找到针对我的特定问题的解决方案。

现在我的 URL 结构就像
www.abc.com/in/something/bla

我更改了一些设置并删除了 /in/,现在 URL 结构是
www.abc.com/something/bla

我想永久重定向到新结构。

我在@stackoverflow 和网络上找到的所有解决方案都没有为我工作,因此我在下面粘贴(部分)我的 htaccess 代码。除了删除 /in/ 外,它工作得很好。
提前感谢您帮助我!

<IfModule mod_rewrite.c>

# Enable Rewrite Engine
# ------------------------------
RewriteEngine On

RewriteBase /

# Redirect index.php Requests
# ------------------------------
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteCond %{THE_REQUEST} !/system/.*
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L]

# Standard ExpressionEngine Rewrite
# ------------------------------
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

# remove trailing slash
# 05.10.2012
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteRule ^(.+)/$  /$1 [R=301,L]
4

2 回答 2

1

使用 mod_alias:

Redirect 301 /in/ /

使用 mod_rewrite:

RewriteRule ^/?in/(.*)$ /$1 [L,R=301]

你会想把那些靠近顶部的,就在你的下面RewriteBase

于 2012-10-06T09:50:32.220 回答
0

试试这个:

RewriteCond %{REQUEST_URI}  ^/in/.*
RewriteRule ^/in(/?.*)$ http://${HTTP_HOST}$1 [P,L]
于 2012-10-06T09:24:14.847 回答