Masking the folder name in the url using htaccess

牧云@^-^@ 提交于 2019-12-24 07:09:34

问题


I am trying to get my new version website online. I have already set up and tested the 301's to direct the files from www.example.com/shop to www.example.com/test. The only thing I now need to be able to do is make the url to show only www.example.com without the /test. In terms of link structure I really don't want this extra folder in there.

I feel I am getting close, but have been at this for days and just can't seem to get it to work! Can someone please help?

UPDATE!

Is it possible that software to generate SEO friendly URLs is causing a conflict? Could this be why I am not able to achieve www.example.com rather than www.example.com/test in the URL?

EDIT

There was a conflict with the config files, which is why I couldn't get the code to work. Thanks for the assistance.


回答1:


in HTTACESS

RewriteEngine On 
RewriteRule ^something\/?$ \/something\/else\/ 



回答2:


If you want to run application located in a subfolder test/ in the root directory, use following rewrite rules and place them in root folders .htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^test/
RewriteRule ^(.*)$ /test/$1 [L,QSA]

Then requests to:

http://www.example.com/yourscript.php
http://www.example.com/css/style.css
http://www.example.com/images/logo.png

Will show results from (if they don't exists in the above location):

http://www.example.com/test/yourscript.php
http://www.example.com/test/css/style.css
http://www.example.com/test/images/logo.png


来源:https://stackoverflow.com/questions/13433876/masking-the-folder-name-in-the-url-using-htaccess

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!