我可以在这里使用一些帮助.我正在使用它来修复我的URL,但我无法弄清楚如何删除.php扩展名.URL现在看起来像这样:http://mydomain.com/page.php/foo/123/bar/456
function decode_URL_parameters() {
$path = @$_SERVER['PATH_INFO'];
$url_array=explode('/',$path);
array_shift($url_array);
while ($url_array) {
$_GET[$url_array[0]] = $url_array[1];
array_shift($url_array);
array_shift($url_array);
}
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
/托比亚斯
我们需要估算基于ColdFusion技术的门户.我们没有关于托管环境的信息(可能是Windows或Linux).
请求的功能之一是干净的URL.有谁知道这是否可以通过纯ColdFusion解决方案实现,还是这总是与Web服务器相关?我知道IIS7有很好的扩展,可以启用干净的URL,但我担心我们不能依赖它们.
我想让我的所有网址统一干净.这意味着我的所有网址都没有扩展名,也没有斜杠,如果某人确实输入了.php
斜杠或尾随斜杠,它只会将此人重定向到干净的网址.
例:
example.com/blog/file.php
Run Code Online (Sandbox Code Playgroud)
和
example.com/blog/file/
Run Code Online (Sandbox Code Playgroud)
会重定向到
example.com/blog/file
Run Code Online (Sandbox Code Playgroud) 我刚安装并开始使用Drupal 7,我按照说明打开Clean Urls.我点击了"运行清洁URL测试"按钮,但无法返回任何结果.它会加载某些内容然后刷新页面.如说明书中所述,没有选项可以启用干净的URL.有人可以帮忙吗?
我正在使用Apache将我的URL重写为干净的URL.
RewriteRule ^(.*) index.php
Run Code Online (Sandbox Code Playgroud)
目前这也重写了目录,这就是我想要的,因为我希望一切都通过我的router/index.php文件运行.
但是我想要做的是有一个我可以直接访问的文件夹.这适用于.js和.css文件等lib文件.我知道如何使用Alias执行此操作,但我无法在.htaccess文件中使用它,我需要使用它.
我怎么能不重写特定的文件夹,例如.叫"lib"?
编辑:
我确实找到了以下如何在.htaccess中伪造Alias的示例,但我无法使其工作:
RewriteRule /old-folder /new-folder [PT]
Run Code Online (Sandbox Code Playgroud) 我怎么能自动将一个站点从脏URL重定向到干净的URL在PHP,如
http://www.mysite.com?page=page1&action=action1
Run Code Online (Sandbox Code Playgroud)
至
http://www.mysite.com/page1/action1
Run Code Online (Sandbox Code Playgroud) 我使用Google App Engine上传了客户的网页,并且运行正常。这是一个非常简单的网页,包含12个静态文件(全部为.html)
我必须删除该文件,但我不知道是否可以通过修改app.yaml或 main.py
例如:我有www.example.com/page.html
,我想要www.example.com/page
我想知道是否可以将扩展名 .php 更改为“/”。
例子:
http://localhost/website/example.php?id=19
转换为,
或者,如果你们对地址有更好的想法,我想知道我应该使用什么。
我是干净 URL 的初学者。
坎普斯。
我的网站目前处理这样的URL ...
/?p=home
/?p=profile&userid=1
/?p=users.online
/?p=users.online&page=23
/?p=mail.inbox
/?p=mail.inbox&page=12
Run Code Online (Sandbox Code Playgroud)
...等等,可能至少有120-150个不同的页面,在我的网站上,这样的页面是这样构建的,
的index.php包括主配置文件,然后包括功能/类文件到它
的index.php然后包括一个头文件
的index.php然后包括页面文件,其是从该URL P =页面名
的index.php然后包括一个脚注文件
这就是我网站上每个页面的编译方式,通过这样的索引页面,我一直在考虑/考虑清理URL,因为我现在正在重写/重构我的大部分网站代码,这是一个完美的时间.如果我要这样做的话.清理URL的意思是使用mod-rewrite,所以上面的URL结构看起来像这样......
/home
/users/1 //user ID might switch to use username as well
/users/online
/users/online/23 or /users/online/page/23
/mail/inbox
/mail/inbox/12
Run Code Online (Sandbox Code Playgroud)
所以首先要做到这一点有什么不足,是否因为使用mod_rewrite而创建了更多的处理工作?
也难以编写正则表达式或者以上面显示的格式匹配文件名所需的任何内容,我只列出了一些页面但是至少有100个不同的URL页面我有博客,公告,论坛,各种各样的东西
如何修改.htaccess文件并获取SEO友好URL而不是查询字符串.我想实现这3个目标:
在另一篇文章中@anubhava给了我很多帮助,这就是我现在对第二点的看法:
RewriteEngine on
RewriteBase /example
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /products(?:\.php)?\?id=([^\s&]+) [NC]
RewriteRule ^ products/%1? [R=302,L,NE]
# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^products/([^/]+)/?$ products.php?id=$1 [L,QSA]
Run Code Online (Sandbox Code Playgroud)
第二点是正常的,但我想知道在之前或之后我必须在哪里放置其他规则.我把它放在另一条规则之后,但它没有用,因为它重定向到上一个url localhost/example/products/38 /:
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} /products(?:\.php)?\?id=([^\s&]+)\?color=([^\s&]+) [NC]
RewriteRule ^ products/%1/%2? …
Run Code Online (Sandbox Code Playgroud) clean-urls ×10
.htaccess ×5
php ×5
mod-rewrite ×4
regex ×2
seo ×2
apache ×1
coldfusion ×1
drupal-7 ×1
html ×1
url ×1