虚荣 URL、.htaccess 问题

发布于 2024-10-02 00:51:57 字数 771 浏览 2 评论 0原文

我试图将虚荣网址添加到我的网页,但它不起作用。 到目前为止,我已经尝试过

RewriteRule ^([A-Za-z0-9]+)[^.]$ index.php?page=$1 [nc]

and

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
RewriteRule ^(.*)$ index.php?page=$1 [NC]

但它不起作用,而且我不知道 .htaccess 语法!

我得到的只是这个错误:

内部服务器错误 服务器遇到内部问题 错误或配置错误,并且是 无法完成您的请求。

请联系服务器 管理员,admin@localhost 和 告知他们错误发生的时间 发生了,以及你可能遇到的任何事情 这样做可能会导致错误。

有关此错误的更多信息可能会 可在服务器错误日志中找到。

你知道我该怎么做吗? 我如何 make.htaccess 将看起来像 www.page.com/vanityurl 的 url 重定向到 index.php?page = $1 但页面变量现在必须是“vanityurl”。

我在本地主机和我的网络服务器上尝试过这个,但我得到了同样的错误!

谢谢你!为您解答! :)

Im trying to add vanity url to my web page, but its not working.
So far I have tried with

RewriteRule ^([A-Za-z0-9]+)[^.]$ index.php?page=$1 [nc]

and

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]
RewriteRule ^(.*)$ index.php?page=$1 [NC]

but its not working, and i dont know .htaccess syntax!

All I got is this error:

Internal Server Error
The server encountered an internal
error or misconfiguration and was
unable to complete your request.

Please contact the server
administrator, admin@localhost and
inform them of the time the error
occurred, and anything you might have
done that may have caused the error.

More information about this error may
be available in the server error log.

Do you know how can I do this?
How can I make.htaccess to redirect my url which looks like www.page.com/vanityurl to index.php?page = $1 but page variable must now be "vanityurl".

I tried this on localhost and on my web server but i get the same error!

Thank you! For your answer! :)

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

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

发布评论

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

评论(1

油焖大侠 2024-10-09 00:51:57

检查 error_log 以了解发生了什么情况。

可能是您的 httpd.conf 未设置为允许在 .htaccess 中指定重写规则。

如果是这种情况,您将在错误日志中看到一条消息例如:

RewriteEngine not allowed here

为了在 .htaccess 中使用重写规则,AllowOverride 设置需要包含 FileInfo 或设置为 All代码> 例如

AllowOverride FileInfo

Check the error_log to find out what is going on.

It might be that your httpd.conf is not set to allow rewrite rules to be specified in .htaccess

If that is the case then you will see a message in the error log like:

RewriteEngine not allowed here

In order to use rewrite rules in .htaccess the AllowOverride setting needs to either include FileInfo or be set to All e.g

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