hide url directory

2019-02-20 01:34发布

I have a website:

www.mydomain.com/subfolder/subfolder/index.php

How could always hide the directory names from the url. I mean always hide the 2 subfolders' names from the url as the page changes.
Example:
These urls:

www.mydomain.com/subfolder/subfolder/index.php
www.mydomain.com/subfolder/subfolder/about.php
www.mydomain.com/subfolder/subfolder/contact.php
...

Becomes:

www.mydomain.com/index
www.mydomain.com/about
www.mydomain.com/contact
...

I want to use the last mentioned urls for requesting these pages, too, without typing a horrible long url.

标签: url
2条回答
趁早两清
2楼-- · 2019-02-20 01:58

you can find some good hints when you will look for mod_rewrite or mod rewrite in htaccess.

查看更多
小情绪 Triste *
3楼-- · 2019-02-20 02:02

If you have access to the Rewrite engine, you can use a simple rewriting pattern similar to this:

RewriteRule ^/(.*)$ /subfolder/subfolder/$1.php
查看更多
登录 后发表回答