Apache htaccess 网址缩短规则

发布于 2024-12-29 20:51:12 字数 302 浏览 4 评论 0原文

我正在尝试创造一些东西 Short.com/ASWi7 -> Short.com/index.php?h=ASWi7

所以我尝试在 htaccess 上使用此代码

RewriteEngine on
RewriteCond %{REQUEST_URI}  !^/index.php
RewriteRule ^(.*)$ /index.php?hash=$1   [L]

,但网站丢失了 css 和所有内容...我在文件夹等中组织了我的网站... 那么我如何排除所有文件夹或某些文件成为该规则的一部分?

I'm trying to create something
short.com/ASWi7 -> short.com/index.php?h=ASWi7

so I tried using this code on my htaccess

RewriteEngine on
RewriteCond %{REQUEST_URI}  !^/index.php
RewriteRule ^(.*)$ /index.php?hash=$1   [L]

but the website loses the css and everything...i organized my site in folder etc...
so how can i exclude all the folders or cetain files to be part of that rule?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

满栀 2025-01-05 20:51:12

请尝试以下操作:

RewriteEngine on

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

!-f 检查现有文件

!-d 检查现有目录

希望有帮助。

Try the following:

RewriteEngine on

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

!-f checks for existing files

!-d checks for existing directories

Hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文