简体   繁体   English

使用htaccess php重写URL

[英]Rewrite URL using htaccess php

I want to rewrite the url in my project. 我想在我的项目中重写网址。

For example: 例如:

http://www.example.com/dashboard/test/ to http://dashboard.example.com/index.php http://www.example.com/dashboard/test/http://dashboard.example.com/index.php

Also I want to do it for: 我也想这样做:

http://www.example.com/dashboard/test2/ to http://dashboard.example.com/index.php http://www.example.com/dashboard/test2/http://dashboard.example.com/index.php

Can anyone tell me the idea to rewrite the url? 谁能告诉我重写网址的想法?

First you create a .htaccess file in your root. 首先,您在根目录中创建一个.htaccess文件。 Than, just put the redirect commands in it. 比,只需将重定向命令放入其中。 How to compose a .htaccess and how to create rewrite rules is explained here: http://net.tutsplus.com/tutorials/other/the-ultimate-guide-to-htaccess-files/ 此处说明了如何编写.htaccess以及如何创建重写规则: http : //net.tutsplus.com/tutorials/other/the-ultimate-guide-to-htaccess-files/

You will need something like: 您将需要以下内容:

RewriteRule ^(.*)$ http://dashboard.example.com/$1 [L,QSA]

try this 尝试这个

 Options +FollowSymLinks
RewriteEngine On
RewriteRule ^test.*$  http://dashboard.example.com/index.php [R=301,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM