我的网站网址:http://example.com/website/pages/home
通缉网址:http://example.com/pages/home
我需要将其作为301重定向,以便搜索引擎更新我的链接。
这是我到目前为止所得到的:
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php index.html
RewriteEngine on
\# remove /website/
RedirectMatch ^(.+)(/website/)(.+)$ $1/$3 [L]
\# remove index.php from URL
RewriteCond $1 !^(index\.php^)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
\# deny access to wget user agent
RewriteCond %{HTTP_USER_AGENT} wget [NC]
RewriteRule (.*) /$1 [L]
此规则会发生什么:
已插入的网址:http://example.com/website/pages/home
重定向的网址:http://example.com/index.php/pages/home
预期结果:http://example.com/pages/home
提前感谢您的帮助。
**的解决* *
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php index.html
RewriteEngine on
# remove /website/
RedirectMatch ^(.+)(index.php/website/)(.+)$ $1$3 [R=301,L]
# remove index.php from URL
RewriteCond $1 !^(index\.php^)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
# deny access to wget user agent
RewriteCond %{HTTP_USER_AGENT} wget [NC]
RewriteRule (.*) /$1 [L]
答案 0 :(得分:0)
RewriteRule ^(。*)$ index.php / $ 1 [L,QSA]
如果从此行中删除index.php怎么办?我想这行会将index.php插入到您的网址中。