[英]Change url by Apache rewrite url
Please help I don't know how can I change the url from the starting (home page) .请帮助我不知道如何从开始(主页)更改 url。
I want to change the url from:我想将 url 从:
localhost/training/test/home.php
To:至:
localhost/test/home
How can I change the url?如何更改 url? Please help me.请帮我。
Try:尝试:
RewriteEngine On
RewriteRule ^\/test\/home$ /training/test/home.php [QSA,L]
You will have to add this the .htaccess file, or to httpd.conf.您必须将此 .htaccess 文件或 httpd.conf 添加。
Make sure mod_rewrite is enabled in your server first.确保首先在您的服务器中启用 mod_rewrite。
If the above doesn't work, then try clearing the browser cache, or try this:如果上述方法不起作用,请尝试清除浏览器缓存,或尝试以下操作:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^\/test\/home$
RewriteRule ^ /training/test/home.php [QSA,L]
If you want to do a 301 redirect in the browser, change [QSA,L]
to [R=301,QSA,L]
.如果要在浏览器中进行 301 重定向,请将[QSA,L]
更改为[R=301,QSA,L]
。
If you want to do a 302 redirect in the browser, change [QSA,L]
to [R=302,QSA,L]
如果要在浏览器中进行 302 重定向,请将[QSA,L]
更改为[R=302,QSA,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.