更新时间:2023-09-25 21:49:52
启用的mod_rewrite
和的.htaccess
到的httpd.conf
,然后把这个code在的.htaccess
在 DOCUMENT_ROOT
目录
选项+了FollowSymLinks -MultiViews
#开启mod_rewrite的上
RewriteEngine叙述上
的RewriteBase /
重写规则^公文包/(.*)$ / $ 1 [L,NC,R]
说明:以上规则匹配的URL图案与公文包启动
并具有财产以后像 /公文包/ XYZ /应用
和看跌
。它使一个外部重定向 XYZ /应用
$ 1 / $ 1
即 / XYZ /应用程序
。
这些都是使用的标志:
L - 最后
NC - 忽略(无)情况相比,
的R - 外部重定向(与302) - 可以被改变为R = 301
I want to change the URL from:
http://domain.com/Portfolios/iPhone/app
To:
http://domain.com/iPhone/app
And same for all URLs like:
domain.com/Portfolios/iPad/app
To:
domain.com/iPad/app
And from:
domain.com/Portfolios/xyz/app
To:
domain.com/xyz/app
I have tried a lot but nothing is working for me, so please help me.
When I need help why any buddy down voting it, if you know the answer then answer it.
Update
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^Portfolios(/.*|)$ $1 [L,NC]
</IfModule>
Enable mod_rewrite
and .htaccess
through httpd.conf
and then put this code in your .htaccess
under DOCUMENT_ROOT
directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^Portfolios/(.*)$ /$1 [L,NC,R]
Explanation: Above rules is matching URL patter that starts with Portfolios
and have somthing like /Portfolios/xyz/app
and puts xyz/app
in $1
. It makes an external redirection to /$1
i.e. /xyz/app
.
These are the flags used:
L - Last
NC - Ignore (No) Case comparison
R - External redirection (with 302) -- can be changed to R=301