php - htaccess need name in front of domain

230

So i have a file named page.php, which has 2 get variables. the u and edit so at the moment i have

mysite.com/page.php?u=dan &
mysite.com/page.php?u=dan&edit

But how can i make the url look like this using htaccess?

dan.mysite.com &
dan.mysite.com/edit

At the moment i have tried this

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ page.php?u=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ page.php?u=$1

but this just makes

mysite.com/dan
945

Answer

Solution:

If I understand your requirement correctly, you can use:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\w-]+)/?$ page.php?u=dan&$1 [L,QSA]

People are also looking for solutions to the problem: php - How do I make Buttons in Wordpress site?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.