【问题标题】:Simple question about htaccess rewrite关于 htaccess 重写的简单问题
【发布时间】:2011-05-19 23:14:33
【问题描述】:

我不太懂rewrite,想做下面的事情……

我有http://www.website.com/web.php?id=3

但我想要http://www.website.com/web/title/3

这可能吗? (title是url网页标题标签)

谢谢。

【问题讨论】:

    标签: html url .htaccess url-rewriting


    【解决方案1】:

    是的,这是可能的。您可以在.htaccess 文件中添加以下内容

    RewriteEngine on
    RewriteRule ^web/([a-zA-Z0-9_-]+)/([0-9]+)\$ web.php?id=$2
    

    更多提示:http://roshanbh.com.np/2008/03/url-rewriting-examples-htaccess.html

    【讨论】:

    • 谢谢 Zain,但它对我不起作用:S 在 .htaccess 上无论有没有这个,我都没有得到完全相同的结果:S 有什么想法吗?
    • 确保您的.htaccess 文件位于根目录中。
    • 它位于根目录:S
    • 您是否更改了所有 URL 以适应新模式 website.com/web/title/3?您必须自己完成此操作,mod_rewrite 只是将您的新 URL 转换为原始 URL。
    • 我刚刚添加了这个:RewriteEngine on RewriteRule ^categoria/([a-zA-Z0-9_-]+)/([0-9]+)\$ categoria.php?id=$2
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-07
    • 2023-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多