2014-01-14 61 views
-4

我想例如使这个:我怎样才能改变一个PHP页面的URL与Apache

原始地址:domain.com/folder/index.php?i=something

更改网址:domain.com/folder/something

但保持原始URL的内容,用Apache的RewriteRule。有人可以告诉我一个很好的教程或如何使用它的文档?

+1

您应该去看这篇文章:http://stackoverflow.com/questions/1039725/how-to-url-re-writing-in- php – freddy

回答

-1
# Open The RewriteEngine 
RewriteEngine On 

RewriteBase/

# Rewrite 

RewriteCond %{QUERY_STRING} ^(.*)$ 
RewriteRule ^bbs/test-([0-9]+)\.html$ bbs/test.php?id=$1&%1 

RewriteCond %{QUERY_STRING} ^(.*)$ 
RewriteRule ^jingdian-([0-9]+)\.html$ jingdian.php?id=$1&%1 
+0

你的回答是完全错误的 –

0

打开httph.conf罚款:#LoadModule rewrite_module模块/ mod_rewrite.so,然后取消# (的LoadModule rewrite_module模块/ mod_rewrite.so) 创建.htaccess文件

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

RewriteCond %{HTTP_HOST} ^domain.com$ [OR] 
RewriteCond %{HTTP_HOST} ^www.domain.com$ 
RewriteCond %{REQUEST_URI} !^/folder/ 
RewriteRule (.*) /folder/$1 

你配置错误 ErrorDocument Error_code /error.html 示例:ErrorDocument 404/error_404.html