PHP $_GET[] Mod Rewrite
I've made a website, and page links are formed like this: ?page=projects_project1
.
projects/project1
. So ?page=
should be removed, and _
should be replaced by /
... So what's being accessed now using ?page=projects_project1
, should become accessible at projects/project1
...
What do I need to put in my .htaccess
file to ac开发者_JS百科hieve this? Please also explain how it is done, so I can do it myself next time.Try this out:
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^([^/]+)/([a-z0-9_]+)$ index.php?page=$1_$2 [NC,L]
The first line says that it should follow the symbolic links that may exist, the second line actually switches on the RewriteEngine
and the third matches links that look like the following:
anything_except_a_forward_slash/anything_here_that_is_an_alphanumeric_or_forward_slash
精彩评论