在用户不可见的情况下重写 URL
Rewriting URL without the user seeing it
我尝试在我的 htaccess 中添加一条规则,以便我可以将所有文章 url 路由到同一文件加载。
Input: localhost/Project/article/my-test-article
Output: localhost/Project/article.php?id=my-test-article
我目前正在使用此代码...有效:
#Enable backend url rewriting
Options +FollowSymLinks
RewriteEngine On
RewriteBase /Project/
#Route articles
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^artikkel/(.*)$ article.php?id= [R]
问题是,我不希望用户能够看到 ?id=my-test-article
!
我根本不想 url 改变,真的。
我只需要它始终加载同一个文件!
我需要做什么才能做到这一点?
我正在使用 WAMP。
如果您不希望 url 在浏览器中发生变化,请删除 R 标志。
Options +FollowSymLinks
RewriteEngine On
RewriteBase /Project/
#Route articles
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^artikkel/(.*)$ article.php?id= [NC,L]
我尝试在我的 htaccess 中添加一条规则,以便我可以将所有文章 url 路由到同一文件加载。
Input: localhost/Project/article/my-test-article
Output: localhost/Project/article.php?id=my-test-article
我目前正在使用此代码...有效:
#Enable backend url rewriting
Options +FollowSymLinks
RewriteEngine On
RewriteBase /Project/
#Route articles
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^artikkel/(.*)$ article.php?id= [R]
问题是,我不希望用户能够看到 ?id=my-test-article
!
我根本不想 url 改变,真的。
我只需要它始终加载同一个文件!
我需要做什么才能做到这一点? 我正在使用 WAMP。
如果您不希望 url 在浏览器中发生变化,请删除 R 标志。
Options +FollowSymLinks
RewriteEngine On
RewriteBase /Project/
#Route articles
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^artikkel/(.*)$ article.php?id= [NC,L]