更改 url .htaccess php

发布于 2024-12-28 13:08:28 字数 491 浏览 2 评论 0原文

我有一个页面名称 page.php ,我的网址为 localhost/mysite/page.php ,现在如何使用 .htaccess 更改网址> 文件到 localhost/mysite/somethinghere1/somethinghere2/page.php

它尝试使用下面的代码,但没有成功。

<IfModule mod_rewrite.c>
# Enable Rewriting 
RewriteEngine On 

# Rewrite user URLs 
#   Input:  user/NAME/ 
#   Output: user.php?id=NAME 

RewriteRule ^somethinghere1/somethinghere2/.php? page.php

</IfModule>

我怎样才能做到这一点。

I have a page name page.php and my url as localhost/mysite/page.php , now how can i change the url using .htaccess file to localhost/mysite/somethinghere1/somethinghere2/page.php

It tried using the below code but it doesn't work out.

<IfModule mod_rewrite.c>
# Enable Rewriting 
RewriteEngine On 

# Rewrite user URLs 
#   Input:  user/NAME/ 
#   Output: user.php?id=NAME 

RewriteRule ^somethinghere1/somethinghere2/.php? page.php

</IfModule>

how can i acheive this.

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

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

发布评论

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

评论(3

揽清风入怀 2025-01-04 13:08:28

这个怎么样:

RewriteRule ^somethinghere1/somethinghere2/([^/\.]+).php/?$ page.php

What about this:

RewriteRule ^somethinghere1/somethinghere2/([^/\.]+).php/?$ page.php
秋日私语 2025-01-04 13:08:28

像这样使用它:

RewriteRule ^(mysite/)somethinghere1/somethinghere2/(.*\.php)/?$ $1$2 [L,NC]

还要确保它位于 DOCUMENT_ROOT 目录中的 .htaccess 文件中。

Use it like this:

RewriteRule ^(mysite/)somethinghere1/somethinghere2/(.*\.php)/?$ $1$2 [L,NC]

Also make sure this in .htaccess file in your DOCUMENT_ROOT directory.

策马西风 2025-01-04 13:08:28
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([^/]+)/([^/]+)/page.php /page.php?first=$1&second=$2 [NC]

这是基本代码,您可以使用它来满足您的需求,如以下编辑:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([^/]+)/([^/]+)/([^/]+) /$3.php?first=$1&second=$2 [NC]

所以 x/y/z 将是 z.php?first=x&second=y

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([^/]+)/([^/]+)/page.php /page.php?first=$1&second=$2 [NC]

This is the basic code , you can play with it to fit your needs like the following edit :

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^([^/]+)/([^/]+)/([^/]+) /$3.php?first=$1&second=$2 [NC]

So x/y/z would be z.php?first=x&second=y

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