我有一个类似于 example.com/x
如何使用 htaccess 将其重定向到 example.com/y
。
顺便说一句,我不想丢失其余的网址。
当前 .htaccess 文件看起来像;
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^(.*)\.[\d]+\.(css|js)$ $1.$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [NC,QSA,L]
</ifModule>
最佳答案
查看 documentation :
RewriteEngine on
RewriteRule ^/x/(.+) /y/$1 [R,L]
关于.htaccess - 如何使用 htaccess 将 example.com/x/restofurl 重定向到 example.com/y/restofurl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13221806/