我想将我的动态网址更改为静态网址,因为请帮助我。 吹我的PHP代码和htaccess代码请更正问题
动态网址:http://localhost/new/books_list.php?subject_id=2
静态网址:http://localhost/new/books_list/subject_id/2/
php代码:
<?php
$connect=mysql_connect("localhost","root","");
$select=mysql_select_db("test",$connect);
if($_REQUEST[subject_id]!=""){
$subject_id=$_REQUEST[subject_id];
htaccess代码:
Options +FollowSymLinks
RewriteEngine on
RewriteRule books_list/subject_id/(.*)/ books_list.php?subject_id=$1
RewriteRule books_list/subject_id/(.*) books_list.php?subject_id=$1
帮我解决这个问题。 感谢
答案 0 :(得分:0)
i have a code like this check that and change as per your requirement
# Enable mod_rewrite, start rewrite engine
Options +FollowSymLinks
RewriteEngine on
#
# Internally rewrite search engine friendly static URL to dynamic filepath and query
RewriteRule ^product/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$ /index.php?product=$1&color=$2&size=$3&texture=$4&maker=$5 [L]
#
# Externally redirect client requests for old dynamic URLs to equivalent new static URLs
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\?product=([^&]+)&color=([^&]+)&size=([^&]+)&texture=([^&]+)&maker=([^\ ]+)\ HTTP/
RewriteRule ^index\.php$ http://example.com/product/%1/%2/%3/%4/%5? [R=301,L]