[英]Multiple URL rewrites with .htaccess
我的.htaccess文件中有以下代碼,位於“root / mosaicin /”目錄中。
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /mosaicin/
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(download-sample-papers|album|results|testimonials)/([^/]+)/?$ /$1.php?url=$2 [NC,QSA,L]
我想將我的網址www.domain.com/mosaicin/album.php/NID/重寫為domain.com/mosaicin/album/NID/與規則中列出的其他網頁相同(結果,推薦等)
我的album.php文件中的示例代碼就像
<?php
$cid = NULL;
$url = new SimpleUrl('/mosaicin/');
if($url->segment(2) == FALSE)
$cname = 'NID';
else
$cname = $url->segment(2);
$cname = urldecode($cname);
$ccsql = "SELECT courseid,cname FROM courses WHERE cname='".$cname."'";
$csql = $obj->select($ccsql);
if(count($csql)>0)
$cid = $csql[0]['courseid'];
?>
獲得courseid后,我的代碼可以列出與特定課程相關的項目。 目前,當我去頁面tplabs.in/mosaicin/album.php/NID一切正常,但鏈接下面的tplabs.in/mosaicin/album/NID它給出404錯誤。
請幫助,提前致謝。
在DOCUMENT_ROOT/.htaccess
文件中嘗試以下規則:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /mosaicin/
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(download-sample-papers|album|results|testimonials)/([^/]+)/?$ $1.php?url=$2 [NC,QSA,L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.