I've made a website, and page links are formed like this: ?page=projects_project1.
I want the pages to be accessible this way as well: 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 achieve this? Please also explain how it is done, so I can do it myself next time.
Add a comment
|
1 Answer
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
15 Comments
RobinJ
... That didn't go too well...
Internal Server Error.karllindmark
Ooops, forgot one of the important keywords - fixed!
RobinJ
Error 310 (net::ERR_TOO_MANY_REDIRECTS): There are too many redirects.
karllindmark
It seems like something is keeping your redirects from ending. Are you manually redirecting in the file that serves your pages?
RobinJ
If
$_GET['page'] is empty: header('Location: ?pagina=home');. Can that possibly be the problem? |