简体   繁体   中英

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

Also I want to do it for:

http://www.example.com/dashboard/test2/ to 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. 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/

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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