문제

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.

도움이 되었습니까?

해결책

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]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top