【问题标题】:url rewriting for address bar in php [duplicate]php中地址栏的url重写[重复]
【发布时间】:2015-05-06 10:45:45
【问题描述】:

我只想在地址栏中重写网址

https://www.tinycent.com/web/single_post.php?slug=samsung-sprint

到

https://www.tinycent.com/web/single_post/samsung-sprint

任何人都可以帮助我解决这件事,我也看到了它需要以更好的方式

在 stackoverflow 或其他上有更多 10 个演示,但他不适合我。

【问题讨论】:

标签: php html .htaccess url url-rewriting


【解决方案1】:

你可以这样做

    RewriteEngine On
    RewriteRule ^web/single_post/([^/]*)$ /web/single_post.php?slug=$1 [L]

【讨论】:

  • 嘿,Kamran,谢谢回复,但问题没有解决,我的意思是那行不通.......
  • 您能否分享您的目录结构,以便提供更好的建议,请确保您的服务器上启用了 Apache mod 重定向。
  • tinycent.com/web/…,web 是用于测试的子文件夹,single_post.php 我只需要 url tinycent.com/web/IPL-2015-RCB-v-MI-Highlights
  • 你能分享你的.htaccess文件吗?
  • Options +FollowSymlinks RewriteEngine on RewriteRule ^/web/single_post/([^/]*)$ /web/single_post.php?slug=$1 [L] RewriteCond %{HTTP_HOST} ^107\。 180\.2\.62 RewriteRule (.*) tinycent.com/$1 [R=301,L] RewriteCond %{HTTP_USER_AGENT} libwww-perl.* RewriteRule .* – [F,L] RewriteBase / RewriteCond %{SERVER_PORT} !^ 443$ RewriteCond %{HTTPS} 关闭 RewriteRule ^(.*)$ tinycent.com/$1 [R=301,L]
猜你喜欢
  • 2011-01-06
  • 2013-02-15
  • 2014-10-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-12
  • 1970-01-01
  • 2014-08-17
相关资源
最近更新 更多