简体   繁体   English

试图让mod_rewrite规则起作用

[英]Trying to get mod_rewrite rule to work

I'm trying to get an htaccess rewrite rule working and not having any luck. 我正在尝试使htaccess重写规则有效,并且没有任何运气。 I've gone through a couple tutorials and can get redirects working, but not rewrite (which is what I need). 我已经完成了一些教程,可以使重定向工作,但不能重写(这是我所需要的)。

Can someone please point me in the right direction? 有人可以指出正确的方向吗?

I want users to enter this URL: 我希望用户输入以下URL:

http://example.com/sample-article

Actual page content: 实际页面内容:

http://example.com/live-site/testing-2012/article-123/

My htaccess rule 我的htaccess规则

RewriteEngine on
RewriteRule ^/sample-article$ http://example.com/live-site/testing-2012/article-123/ [NC,L]

Your help is greatly appreciated. 非常感谢您的帮助。

Cheers 干杯

Try to remove the leading / : 尝试删除前导/

RewriteEngine on
RewriteRule ^sample-article$ /live-site/testing-2012/article-123/ [NC,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM