2017-02-17 140 views
0

我想將我的動態網址更改爲靜態網址,請幫助我。 吹我的PHP代碼和htaccess的代碼,請糾正問題動態網址到靜態網址更改

動態網址:http://localhost/new/books_list.php?subject_id=2

靜態URL: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 

幫我解決了這個問題。 感謝

+2

這錯字太多汁修復... – Benjamin

+1

請解釋一下你的問題是什麼,錯誤等你試圖解決它。 – Benjamin

+0

我需要將動態網址更改爲靜態只有先生 – Jayabal

回答

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]