2013-07-15 26 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]