How to add a custom word to my domain URL for every request?

心不动则不痛 提交于 2019-12-04 19:33:49

You could create the directory "register", and put an index file inside it that performs the action.

That's probably the simplest way without url rewriting anyway.


UPDATE (since the question was updated)

In .htaccess:

RewriteEngine On
RewriteRule ^([A-Za-z0-9-.]+)/user/register/?$ user/register.php?customword=$1

register.php will receive a GET request:

//User went to www.mydomain/word/user/register
echo $_GET['customword']; // will return word in this case

Make sure that you have mod_rewrite enabled :)

Yes, you can do it with htaccess

Here is an example which will add a trailing slash with url if it doesnt contain trailing slash

http://enarion.net/web/htaccess/trailing-slash/

ElCangri

edit formatting updated
If you are serving one site from this then the following should work:

Edit your .htaccess file to do a url rewrite

accessing www.yourdomain.com/user/registry will actually server content from www.yourdomain.com/customword/user/registry

RewriteEngine On<br>
RewriteCond %{REQUEST_URI} !^/customword/<br>
RewriteRule ^(.*)$ /customword/$1

You haven't mentioned what kind of site you;re using..eg: PHP, MVC etc as you could do similar thing in there as well.

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