my question has two parts.

first what does this mean?

Rewriterule ^(.*)$ http://www.somedomain.com/$1 [r=301,nc]

and the second part is that i want to Rewrite this

somedomain.com/somename

to go to

somedomain.com/index.php?page=user&p=somename

if you are providing me a new code do i have to replace the code mentioned above?

有帮助吗?

解决方案

The short simple answer.

Rewriterule ^(.*)$ http://www.somedomain.com/$1 [r=301,nc]

This rule will match anything after the / and the 2nd part of the rule will take that match and add it after the domain name of www.somedomain.com and then redirect that new URL. The new URL will be shown in the address bar.

For what you want to do, that rule won't work. You will need to do this.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
Rewriterule ^(.+)$ index.php?page=user&p=$1 [L]

This will be an internal redirect so that what shows in your address bar will be a URL like

http://somedomain.com/somename
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top