0

我正在尝试使用我的 htaccess 来允许我发送一个漂亮的 url 并将其路由到常规网页。

因此,当我发送“ 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]

谢谢!

4

2 回答 2

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]
于 2013-07-31T11:29:57.620 回答
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]
于 2013-07-15T13:00:46.083 回答