我确信之前已经问过这个问题,但出于某些原因,无论我尝试什么似乎都不起作用。
我拥有的是: http://example.com/share/edit.php?id=59
我想要的是: http://example.com/share/59
我的.htaccess
是:
RewriteEngine on
RewriteRule ^share/([0-9]+)$ share/edit.php?id=$1
我做错了吗? .htaccess
文件位于example.com/share
目录中。
答案 0 :(得分:0)
尝试将.htaccess
放到example.com
目录。
答案 1 :(得分:0)
尝试这样做:
RewriteEngine On
RewriteRule ^share/([^/]*)$ /share/edit.php?id=$1 [L]
您的.htaccess
文件应位于根目录,即example.com
的目录中。那里有share
文件夹。
答案 2 :(得分:0)
如果.htaccess位于共享目录中,则无需指定URL路径。尝试这样的事情:
RewriteEngine On RewriteRule ^(.*)$ edit.php?id=$1 [QSA,L]
不言而喻,如果您使用apache,则需要启用mod_rewrite。
答案 3 :(得分:-1)
'.htaccess'文件位于'example.com/share'目录中。
将其移至上一级目录(public_html或www)。