link 自动在 link 中添加一个斜杠 (/) 并在 php 中销毁我的 link
link automatic add a slash(/) itself inlink and destroy my link in php
我的 link 用于另一页 news.php 是 :-
href="news?id=etc"
这里我把href.
中新闻后的.php
去掉
我在 .htaccess 文件中使用以下代码删除 .php 扩展名:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ .php [NC,L]
然后我点击link后,URL打开页面后是这样的:
http://localhost/themobilesapp/news?id=15
但它自动转换为:
http://localhost/themobilesapp/news/?id=15
它在 /news
之后的 .php
位置添加了一个斜杠 (/)
请帮我删除这个斜杠(/)
这应该适合你
RewriteEngine On
RewriteRule ^themobilesapp/news\?id\=([^/]*)$ /themobilesapp/news.php?id= [L]
它会将原来的 URL 转换为:
http://localhost/themobilesapp/news.php?id=15
到
http://localhost/themobilesapp/news?id=15
但从我的角度来看,它看起来会更好:
http://localhost/themobilesapp/news/id/15
如果你喜欢它而不是使用:
RewriteEngine On
RewriteRule ^themobilesapp/news/id/([^/]*)$ /themobilesapp/news.php?id= [L]
我的 link 用于另一页 news.php 是 :-
href="news?id=etc"
这里我把href.
中新闻后的.php
去掉
我在 .htaccess 文件中使用以下代码删除 .php 扩展名:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ .php [NC,L]
然后我点击link后,URL打开页面后是这样的:
http://localhost/themobilesapp/news?id=15
但它自动转换为:
http://localhost/themobilesapp/news/?id=15
它在 /news
之后的.php
位置添加了一个斜杠 (/)
请帮我删除这个斜杠(/)
这应该适合你
RewriteEngine On
RewriteRule ^themobilesapp/news\?id\=([^/]*)$ /themobilesapp/news.php?id= [L]
它会将原来的 URL 转换为:
http://localhost/themobilesapp/news.php?id=15
到
http://localhost/themobilesapp/news?id=15
但从我的角度来看,它看起来会更好:
http://localhost/themobilesapp/news/id/15
如果你喜欢它而不是使用:
RewriteEngine On
RewriteRule ^themobilesapp/news/id/([^/]*)$ /themobilesapp/news.php?id= [L]