Question

I want to type www.mysite.com/page1 in the browser

but I want the server to get this. www.mysite.com/index.php?page=1

and I want the former address www.mysite.com/page1 to stay persistent in the browser address bar. Is this possible?

I assume it's a mod rewrite but I really have trouble with that file.

Thanks.

Was it helpful?

Solution

Enable mod_rewrite and .htaccess through httpd.conf (if not already enabled) and then put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/?$ /index.php?page=$1 [L,NC,QSA]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top