我想从改变网址:
http://domain.com/Portfolios/iPhone/app
要:
http://domain.com/iPhone/app
和同样像所有网址:
domain.com/Portfolios/iPad/app
要:
domain.com/iPad/app
和来自:
domain.com/Portfolios/xyz/app
要:
domain.com/xyz/app
我已经尝试了很多,但没有什么工作适合我,所以请帮助我。
当我需要帮助,为什么任何哥们倒投票吧,如果你知道答案,然后回答吧。
更新
< IfModule mod_rewrite.c>
RewriteEngine叙述上
重写规则^投资组合(/.* |)$ $ 1 [L,NC]
< / IfModule>
解决方案
启用的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