的.htaccess URL重写不工作 [英] .htaccess URL rewrite does not work

查看:101
本文介绍了的.htaccess URL重写不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了.htaccess文件转换网址,搜索引擎友好:

I've wrote .htaccess file to convert urls to SEO friendly :

原始URL是:

http://palestinianz.com/?page=person&p=Alex-Atalla

的.htaccess的含量为:

the content of .htaccess is :

RewriteEngine On
RewriteRule ^([^/]*)\.html$ /?page=person&p=$1 [L]

它应该产生这样一个链接:

it should produce a link like this :

http://palestinianz.com/Alex-Atalla.html

不过,这都没有影响,虽然我把文件在我的网站的根! 问题出在哪里?

But it makes no effect although I put the file in the root of my website ! where is the problem ?

推荐答案

如果你想在地址栏更改URL,你需要重定向浏览器,然后重新编写服务器上。这个答案的第一部分介绍了所需的过程: http://stackoverflow.com/a/11711948/851273

If you want the URL to change in the address bar, you need to redirect the browser, then rewrite on the server. The first part of this answer explains the process that you want: http://stackoverflow.com/a/11711948/851273

所以,在看第二个列表,这个过程是将浏览器重定向,如果一个丑陋的链接请求一个很好看的链接:

So looking at the second list, the process is to redirect the browser if an ugly link is request to a nice looking link:

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /\?page=person&p=([^\ ]+)
RewriteRule ^$ /%1.html? [R=301,L]

现在,在服务器端需要internall回丑陋的URL重写一遍,这或多或少是你已经拥有的:

Now, on the server end you need to internall rewrite it back to the ugly url, which is more or less what you already have:

RewriteRule ^([^/]*)\.html$ /?page=person&p=$1 [L]

这篇关于的.htaccess URL重写不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆