如题,还是说有其他特殊的方法呢??非框架,手写项目的话回复内容:如题,还是说有其他特殊的方法呢??非框架,手写项目的话用 Nginx 做个跳转。所以要用框架啊,输出链接要用函数,方便改造。即时不用框架,自己写也得封装输出链接的函数。Nginx try_files 按顺序检查文件是否存在,返回第一个找到的文件或文件夹,如果所有的文件或文件夹都找不到,重定向到最后一个参数按顺序匹配可行?
对于apache的rewrite模块打开和设置则非本文主题,请见其他文章详解. 这个类只能php 5.30以上的版本才能使用,继承了上一个版本的快速重定向的特点(单独类,全部使用静态调用),增添了一个很重要的功能和属性 可以调用其他url中的模块了 也使得模块与模块间或页面与页面间的函数简化共享得以实现 .htaccess文件写法: 代码如下:#-------------- .htaccess start --------------- RewriteEngine on RewriteRule !\.(js|ico|gif|jpg|png|...
Drupal 以下是实现例子: 代码如下:/* * 伪地址转原地址 (url_alter) */ function example_url_inbound_alter(&$path, $original_path, $path_language) { if (preg_match(|^article(/.*)|, $path, $matches)) { $path = node. $matches[1]; } } /* * 原地址转伪地址 (url_alter) */ function example_url_outbound_alter(&$path, &$options, $original_path) { if (preg_match(|^node(/.*)|, $path, $matches)) { $path = articl...
NginxThinkPHP 网上搜了很多方法都不奏效,研究了一天,发现通过以下的配置可以完美支持 'URL_MODEL' => 2 的情况了 代码如下:location /project/ { index index.php; if (!-e $request_filename) { rewrite ^/project/(.*)$ /project/index.php/$1 last; break; } } location ~ .+\.php($|/) { set $script $uri; set $path_info "/"; if ($uri ~ "^(.+\.php)(/.+)") { set $script $1; set $path_info $2; } fastcgi_pass 127.0...
ThinkPHP 代码如下:http://serverName/appName/module/action/id/1/ 这个就是pathinfo模式 在不考虑路由的情况下,第一个参数会被解析成模块名称(如果启用了分组的话,则依次往后递推),第二个参数会被解析成操作,后面的参数是显式传递的,而且必须成对出现,例如:代码如下:http://serverName/appName/module/action/year/2008/month/09/day/21/ 通常的URL里面含有index.php,为了达到更好的SEO效果可能需要去掉URL里面的inde...
ThinkPHP 我想要的结果无非是去掉URL路径中的index.php 首先是配置.htaccess <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] 因为我部署在apache上面,需要httpd.conf配置文件中找到LoadModule rewrite_module modules/mod_rewrite.so去掉前面的#,找到AllowOverride None改为AllowOverride All。 现在访问loca...
ThinkPHP 本文针对ThinkPHP中pathinfo的两种模式、四种路径访问模式和URL重写相关知识进行了总结归纳,分享给大家便于查询和借鉴。具体归纳如下: 1、pathinfo 访问模块IndexAction.class.php下边的test方法http://localhost/index.php?m=Index&a=test 等同于 http://localhost/index.php/Index/test 2、四种路径访问模式在config目录下边来做修改 URL_MODEL的值,分别表述如下: 值为0 叫做普通模式。如:http://localhost/inde...
我想要的结果无非是去掉URL路径中的index.php 首先是配置.htaccess代码如下: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]因为我部署在apache上面,需要httpd.conf配置文件中找到LoadModule rewrite_module modules/mod_rewrite.so去掉前面的#,找到AllowOverride None改为AllowOverride All。 现在访问local...
本文实例讲述了CodeIgniter针对lighttpd服务器URL重写的方法。分享给大家供大家参考。具体实现方法如下: 由于开发环境使用的是lighttpd服务器,我本机环境使用的是Apache配置,导致部署到开发机后,所有的链接地址全部跳转到首页。 分析了下,index.php/controller/function ,controller没有生效,应该是路由分发的缘故。 配置lighttpd配置的url重写规则:url.rewrite-once = ("/(.*)\.(.*)" => "$0","/(css|files|img|js|stats)/...
对于apache的rewrite模块打开和设置则非本文主题,请见其他文章详解. 这个类只能php 5.30以上的版本才能使用,继承了上一个版本的快速重定向的特点(单独类,全部使用静态调用),增添了一个很重要的功能和属性 可以调用其他url中的模块了 也使得模块与模块间或页面与页面间的函数简化共享得以实现 .htaccess文件写法: 代码如下:#-------------- .htaccess start --------------- RewriteEngine on RewriteRule !\.(js|ico|gif|jpg|png|...
以下是实现例子: 代码如下:/* * 伪地址转原地址 (url_alter) */ function example_url_inbound_alter(&$path, $original_path, $path_language) { if (preg_match(|^article(/.*)|, $path, $matches)) { $path = node. $matches[1]; } } /* * 原地址转伪地址 (url_alter) */ function example_url_outbound_alter(&$path, &$options, $original_path) { if (preg_match(|^node(/.*)|, $path, $matches)) { $path = article . $ma...
网上搜了很多方法都不奏效,研究了一天,发现通过以下的配置可以完美支持 'URL_MODEL' => 2 的情况了 代码如下:location /project/ { index index.php; if (!-e $request_filename) { rewrite ^/project/(.*)$ /project/index.php/$1 last; break; } } location ~ .+\.php($|/) { set $script $uri; set $path_info "/"; if ($uri ~ "^(.+\.php)(/.+)") { set $script $1; set $path_info $2; } fastcgi_pass 127.0.0.1:9000; fas...
代码如下:http://serverName/appName/module/action/id/1/ 这个就是pathinfo模式 在不考虑路由的情况下,第一个参数会被解析成模块名称(如果启用了分组的话,则依次往后递推),第二个参数会被解析成操作,后面的参数是显式传递的,而且必须成对出现,例如:代码如下:http://serverName/appName/module/action/year/2008/month/09/day/21/ 通常的URL里面含有index.php,为了达到更好的SEO效果可能需要去掉URL里面的index.php ,通...
本文针对ThinkPHP中pathinfo的两种模式、四种路径访问模式和URL重写相关知识进行了总结归纳,分享给大家便于查询和借鉴。具体归纳如下: 1、pathinfo 访问模块IndexAction.class.php下边的test方法http://localhost/index.php?m=Index&a=test 等同于 http://localhost/index.php/Index/test 2、四种路径访问模式在config目录下边来做修改 URL_MODEL的值,分别表述如下: 值为0 叫做普通模式。如:http://localhost/index.php?m=模...
我想要的结果无非是去掉URL路径中的index.php 首先是配置.htaccess代码如下: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]因为我部署在apache上面,需要httpd.conf配置文件中找到LoadModule rewrite_module modules/mod_rewrite.so去掉前面的#,找到AllowOverride None改为AllowOverride All。 现在访问local...