2013-07-15 48 views
0

我想用我的htaccess來讓我發送一個漂亮的url,並讓它路由到一個普通的網頁。htaccess漂亮的url到普通的php文件

因此,當我發送「http://www.foobar.com/dir1/file/id」時,我希望它路由到「http」// www.foobar.com/dir1/file.php?id=1「正如我所提到的,我一直在嘗試。實現這一目標,通過我的htaccess的文件,但我剛開始404的所有的時間,我在這裏希望大師們的一個可以幫助我

這是我在DIR1目錄的htaccess:

Options +FollowSymLinks 
RewriteEngine on 

RewriteEngine on 
RewriteRule ^dir1/file/([a-zA-Z0-9]+)$ file.php?id=$1 [L] 

謝謝!

回答

0

試試這個工作正常

//First Parameer 
RewriteEngine On 
RewriteRule ^([a-zA-Z0-9_-]+)$ file.php?id=$1 
RewriteRule ^([a-zA-Z0-9_-]+)/$ file.php?id=$1 

//Second Parameter 
RewriteEngine On 
RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)$ users.php?user=$1&page=$2 
RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)/$ users.php?user=$1&page=$2 

或者試試這個

Options +FollowSymLinks 
RewriteEngine On 

# add trailing slash 

RewriteCond %{REQUEST_URI} !(/$|\.) 
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L] 

# rewrite gallery/ to gallery.php 

RewriteCond %{REQUEST_URI} /$ 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)/$ $1.php [L] 

# redirect example.com/index.php to example.com/ 

RewriteCond %{REQUEST_URI} index\.php$ 
RewriteRule ^(.*)index\.php$ /$1/ [R=301,L] 
0

試試這個:

<FilesMatch "\.(tpl|ini|log)"> 
Order deny,allow 
Deny from all 
</FilesMatch> 

在這裏,您可以更改(TPL)。文件到您的需求

,並進一步

# SEO URL Settings 
RewriteEngine On 
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie./becomes /shop/ 

RewriteBase/
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L] 
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css) 
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]