我一直在尝试执行一个mod-rewrite来清理我的网址。我从来没有这样做过。htaccess问题入门
以下是我的一个URL的一个例子:
http://www.example.com/listings.php?category=Accident%20and%20Crash%20Repairs
文件listings.php是在我的网站的根目录下。
我测试过在我的服务器上启用了mod-rewrite,并发现它正常工作。
从一个空白文件开始我试图创建一个.htaccess文件来重写我的网址。以下是我迄今为止尝试:
RewriteEngine On
RewriteRule ^([^/]*)\.html$ /listings.php?category=$1 [L]
RewriteEngine On
RewriteRule ^/listings.html$ /listings.php?category=Accident%20and%20Crash%20Repairs [L]
在下面的例子中,我只是想获得一个部分的URL改变,松散的基础上回答关于堆栈溢出另一查询。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase/
RewriteRule ^lineage/?$ listings.php [NC,L]
</IfModule>
我已经尝试了很多组合,并遵循一些教程。不用说没有任何工作。
如果可能的话,我想的网址显示为:
http://www.example.com/listings/accident-and-crash-repairs
,但如果不是我会满足于没有看到该变量在所有。
任何人都可以指出我出错的地方,或者以任何方式帮助我解决问题吗?
非常感谢。
如果您加载了'http:// www.example.com/lineage /'或'http:// www.example.com/listings.html'或'http://www.example.com/事故%20于是%20Crash%20Repairs.html'?你有404页吗? – Gerben
@Gerben感谢您的评论。没有404页面。页面看起来很好,但没有任何结果。 –
因此'http://www.example.com/listings.php?category = Accident%20and%20Crash%20Repairs'加载您的页面的罚款与所有结果? – anubhava