Gallery: 模块:重写(rewrite):修订间差异

来自站长百科
跳转至: 导航、​ 搜索
(新页面: = URL Rewrite (1.1.x) = Developer Reference ==Description== Provides configurable short URLs using mod_rewrite, ISAPI_Rewrite or PathInfo. ==Features== * Shorten...)
 
→‎特点
 
(未显示同一用户的4个中间版本)
第1行: 第1行:
= URL Rewrite (1.1.x) =
= URL Rewrite (1.1.x) =
[[Gallery:URL_Rewrite|Developer Reference]]
[[Gallery:URL_Rewrite|开发者参考]]


==Description==
==描述==
Provides configurable short URLs using mod_rewrite, ISAPI_Rewrite or PathInfo.
使用mod_rewrite,ISAPI_Rewrite或PathInfo来提供可配置的短URL。


==Features==
==特点==
* Shortens URLs to human readable paths.
* 将URL缩短到人工可读长度的路径。
* Apache mod_rewrite support.
* Apache mod_rewrite支持。
* IIS ISAPI_Rewrite support.
* IIS ISAPI_Rewrite支持。
* PHP PathInfo support.
* PHP PathInfo支持。
* Configurable URL patterns.
* 可配置的URL样式。
* Block hotlinked items (ISAPI_Rewrite and mod_rewrite only)
* 拦截热链(hotlinked)项目(仅ISAPI_Rewrite 和mod_rewrite)。
* Other modules provide extra functionality
* 其他模块提供有额外的功能。
** [[Gallery:Modules:watermark|Watermark]] module: Watermark hotlinked items (ISAPI_Rewrite and mod_rewrite only)
** [[Gallery:Modules:watermark|Watermark]]模块:水印热链(hotlinked)项目(仅ISAPI_Rewrite和mod_rewrite)。
** [[Gallery:Modules:permalinks|Permalinks]] module: Permanent URLs that don't change when you move items.
** [[Gallery:Modules:permalinks|Permalinks]]模块:移动项目时不会改变的永久URL。


==Usage==
==用法==
* Read the [[Gallery:Installing_Additional_Components#Installing_Modules_and_Themes|plugin installation instructions]] to enable the URL rewrite module.
* 参读[[Gallery:Installing_Additional_Components#Installing_Modules_and_Themes|插件安装的相关指导]],并启用URL重写模块(URL rewrite module)。
* You need to configure this module in ''Site Admin -> Plugins''.
* 你需要在''站点管理(Site Admin) -> 插件(Plugins)''中对此模块进行配置。


The configuration page will show you parsing methods available depending on server type (Apache or IIS). If you are unsure of which method to choose you should select either mod_rewrite (Apache) or ISAPI_Rewrite (IIS). The module will test to see if you server supports the parsing method chosen. If all test pass you will be redirected to the Admin Module page and you may now activate the module.
配置页面将显示服务器类型(Aapche或IIS)可用的解析方法。如果你不知道该选择哪种方法,你应该都选择一下看看:mod_rewrite(Apache)或 ISAPI_Rewrite(IIS)。模块将会测试你的服务器是否支持所选的解析方法。如果测试成功的话,就会跳转到模块管理页面,在此就可以激活模块了。


==Requested Features==
==特点请求==
* [http://sourceforge.net/tracker/?func=detail&aid=1224224&group_id=7130&atid=357130| 1224224] Don't append .html to item URLs
* [http://sourceforge.net/tracker/?func=detail&aid=1224224&group_id=7130&atid=357130| 1224224] 请勿将.html作为项目URL的后置
* Change parsing method while the module is active.
* 当模块处于活动状态时对解析方法进行修改。


==Bugs==
==Bug==
Currently there are no known issues for this module.
目前无有关此模块的已知问题。


==Troubleshooting==
==疑难解答==
===How can I check if mod_rewrite is loaded?===
===如何确定mod_rewrite被装载了?===
Go to the Gallery phpinfo page and look for Loaded Modules. You should see mod_rewrite in the list if it's loaded. Note that the list will be empty if you run PHP in cgi mode.
打开Gallery的phpinfo页面查看已装置模块的有关信息。如果mod_rewrite被装载了,就可以在列表中看到它。注意,如果PHP在cgi模式下运行的话,此列表将是空的。
  gallery2/lib/support/index.php?phpinfo
  gallery2/lib/support/index.php?phpinfo


===I know mod_rewrite is loaded, why is Gallery telling me it's not working?===
===我确定mod_rewrite被装载了,但为何Gallery告知我此模块无法运行?===
If you are the server admin make sure the Gallery directory has the proper AllowOverride rights. Gallery needs to be able to override FileInfo and Options. Put this at the end of your Apache configuration:
如果你是服务器管理者的话,请确保Gallery的目录具有合适的AllowOverride权限。Gallery需要能够覆盖FileInfo和Options(选项)。在你的Apache配置的末尾加上:
  <Directory /full/path/to/gallery2>
  <Directory /full/path/to/gallery2>
     AllowOverride FileInfo Options
     AllowOverride FileInfo Options
  </Directory>
  </Directory>


===I lost my .htaccess and now the Site Admin links doesn't work.===
===我的.htaccess文件丢失,而且站点管理(Site Admin)的链接都无效了。===
See also the [[Gallery:FAQ#Images_don.27t_show_up_and_the_album_.2F_photo_links_don.27t_work.2C_what_can_I_do.3F|Gallery2 FAQ]] on this topic.
参见有关此话题的[[Gallery:FAQ#图片无法显示,相册/相片的链接无效,我该怎么办?|Gallery2常见问题]]
Put this in your .htaccess, then go to Site Admin -> URL Rewrite and save the rules to restore your orginal .htaccess.
将以下语句加入你的.htaccess,接着打开站点管理(Site Admin) -> URL重写(URL Rewrite)并保存规则以恢复你原来的.htaccess文件。
  # BEGIN Url Rewrite section
  # 开始Url Rewrite部分
  # (Automatically generated.  Do not edit this section)
  # (自动生成的。请勿编辑此部分)
  <IfModule mod_rewrite.c>
  <IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteEngine On
   
   
     # The path to your Gallery (in this case example.com/gallery2/)
     # Gallery的路径(此例example.com/gallery2/
     RewriteBase /gallery2/
     RewriteBase /gallery2/
   
   
     RewriteRule ^admin /gallery2/main.php?g2_view=core.SiteAdmin  [QSA,L]
     RewriteRule ^admin /gallery2/main.php?g2_view=core.SiteAdmin  [QSA,L]
  </IfModule>
  </IfModule>
  # END Url Rewrite section
  # 结束Url Rewrite部分


=URL Rewrite Embedded=
=URL Rewrite嵌入=
When making any changes to the URL Rewrite configuration (including the rules) you need to access the URL Rewrite admin interface through the embedding application.
当对URL Rewrite配置做任何修改(包括规则)时,你需要通过嵌入应用程序访问URL Rewrite管理界面。


==Configuring Apache mod_rewrite==
==Apache mod_rewrite的配置==
Please make sure the Apache user have write access to the .htaccess file in the directory of which the embedding application resides.
请确保Apache用户具有嵌入应用程序所在文件夹中的.htaccess文件的写访问权限。
  touch /var/www/localhost/embedApp/.htaccess
  touch /var/www/localhost/embedApp/.htaccess
  chmod 666 /var/www/localhost/embedApp/.htaccess
  chmod 666 /var/www/localhost/embedApp/.htaccess
If you are not comfortable with leaving everyone with write access to the .htaccess file you may change it back ''after'' you have completed the setup and don't plan to change any settings (including the rules under the Setup tab).
如果你不愿意让所有人都能写入.htaccess文件的话,你可以在''完成安装之后''恢复以前的设定--并且不计划修改任何设定(包括Setup标签下的规则)。
  chmod 644 /var/www/localhost/embedApp/.htaccess
  chmod 644 /var/www/localhost/embedApp/.htaccess


[[Image:EmbeddedRewrite_-_Clipboard01.jpg|thumb|Access Points]]
[[Image:EmbeddedRewrite_-_Clipboard01.jpg|thumb|Access Points]]
[[Image:EmbeddedRewrite_-_Clipboard02.jpg]]
[[Image:EmbeddedRewrite_-_Clipboard02.jpg]]
#Navigate to the Site Admin -> Url Rewrite -> Setup tab. Again, you need to be in embedded mode to do this.
#打开站点管理(Site Admin) -> URL重写(Url Rewrite) -> 安装(Setup)标签。你需要再次使用嵌入模式来进行此操作。
# Fill out the '''Htaccess path'''. This is the physical location of your embedded mode .htaccess file , /var/www/localhost/embedApp).
# 填写'''Htaccess路径'''。这是你嵌入模式的.htaccess文件的物理位置(/var/www/localhost/embedApp)
# Fill out the '''Public path'''. This is the path to the embedding application that clients will see from the web (eg, /embedApp or /).
# 填写'''Public路径'''。这是嵌入应用程序的路径,客户端将从web看到(如,/embedApp或 /)。


'''Validate'''
'''验证'''
[[Image:EmbeddedRewrite_-_Clipboard05.jpg|thumb|URL Rewrite Tests]]
[[Image:EmbeddedRewrite_-_Clipboard05.jpg|thumb|URL Rewrite Tests]]
[[Image:EmbeddedRewrite_-_Clipboard04.jpg]]
[[Image:EmbeddedRewrite_-_Clipboard04.jpg]]
# Select the '''Test tab''' and look for the '''Embedded tests'''
# 选择'''测试(Test)标签'''并查找'''嵌入的测试'''
# Gallery will test to ensure you have correctly configured the URL Rewrite module.
# Gallery将进行测试,使你确信已对URL Rewrite模块进行了正确配置。


==Configuring IIS ISAPI_Rewrite==
==IIS ISAPI_Rewrite的配置==
[[Image:EmbeddedRewrite_-_Clipboard02.jpg]]
[[Image:EmbeddedRewrite_-_Clipboard02.jpg]]
#Navigate to the Site Admin -> Url Rewrite -> Setup tab. Again, you need to be in embedded mode to do this.
#打开站点管理(Site Admin) -> URL重写(Url Rewrite) -> 安装(Setup)标签。你需要再次使用嵌入模式来进行此操作。
# Fill out the '''Public path'''. This is the path to the embedding application that clients will see from the web (eg, /embedApp/ or /).
# 填写'''Public路径'''。这是嵌入应用程序的路径,客户端将从web看到(如,/embedApp或 /)。
==Configuring PHP Path Info==
==PHP路径信息(PHP Path Info)的配置==
No need to configure embedded mode. You don't need to be in embedded mode when making any changes to the rules since Gallery will parse the rules.
无需配置嵌入模式。在修改规则时,你不需要处于嵌入模式中,因为Gallery将会对规则进行解析。


[[Category:Gallery 2:Modules]]
[[Category:Gallery 2:Modules]]

2008年8月29日 (五) 14:03的最新版本

URL Rewrite (1.1.x)[ ]

开发者参考

描述[ ]

使用mod_rewrite,ISAPI_Rewrite或PathInfo来提供可配置的短URL。

特点[ ]

  • 将URL缩短到人工可读长度的路径。
  • Apache mod_rewrite支持。
  • IIS ISAPI_Rewrite支持。
  • PHP PathInfo支持。
  • 可配置的URL样式。
  • 拦截热链(hotlinked)项目(仅ISAPI_Rewrite 和mod_rewrite)。
  • 其他模块提供有额外的功能。
    • Watermark模块:水印热链(hotlinked)项目(仅ISAPI_Rewrite和mod_rewrite)。
    • Permalinks模块:移动项目时不会改变的永久URL。

用法[ ]

  • 参读插件安装的相关指导,并启用URL重写模块(URL rewrite module)。
  • 你需要在站点管理(Site Admin) -> 插件(Plugins)中对此模块进行配置。

配置页面将显示服务器类型(Aapche或IIS)可用的解析方法。如果你不知道该选择哪种方法,你应该都选择一下看看:mod_rewrite(Apache)或 ISAPI_Rewrite(IIS)。模块将会测试你的服务器是否支持所选的解析方法。如果测试成功的话,就会跳转到模块管理页面,在此就可以激活模块了。

特点请求[ ]

  • 1224224 请勿将.html作为项目URL的后置
  • 当模块处于活动状态时对解析方法进行修改。

Bug[ ]

目前无有关此模块的已知问题。

疑难解答[ ]

如何确定mod_rewrite被装载了?[ ]

打开Gallery的phpinfo页面查看已装置模块的有关信息。如果mod_rewrite被装载了,就可以在列表中看到它。注意,如果PHP在cgi模式下运行的话,此列表将是空的。

gallery2/lib/support/index.php?phpinfo

我确定mod_rewrite被装载了,但为何Gallery告知我此模块无法运行?[ ]

如果你是服务器管理者的话,请确保Gallery的目录具有合适的AllowOverride权限。Gallery需要能够覆盖FileInfo和Options(选项)。在你的Apache配置的末尾加上:

<Directory /full/path/to/gallery2>
    AllowOverride FileInfo Options
</Directory>

我的.htaccess文件丢失,而且站点管理(Site Admin)的链接都无效了。[ ]

参见有关此话题的Gallery2常见问题。 将以下语句加入你的.htaccess,接着打开站点管理(Site Admin) -> URL重写(URL Rewrite)并保存规则以恢复你原来的.htaccess文件。

# 开始Url Rewrite部分
# (自动生成的。请勿编辑此部分)
<IfModule mod_rewrite.c>
    RewriteEngine On

    # Gallery的路径(此例example.com/gallery2/)
    RewriteBase /gallery2/

    RewriteRule ^admin /gallery2/main.php?g2_view=core.SiteAdmin   [QSA,L]
</IfModule>
# 结束Url Rewrite部分

URL Rewrite嵌入[ ]

当对URL Rewrite配置做任何修改(包括规则)时,你需要通过嵌入应用程序访问URL Rewrite管理界面。

Apache mod_rewrite的配置[ ]

请确保Apache用户具有嵌入应用程序所在文件夹中的.htaccess文件的写访问权限。

touch /var/www/localhost/embedApp/.htaccess
chmod 666 /var/www/localhost/embedApp/.htaccess

如果你不愿意让所有人都能写入.htaccess文件的话,你可以在完成安装之后恢复以前的设定--并且不计划修改任何设定(包括Setup标签下的规则)。

chmod 644 /var/www/localhost/embedApp/.htaccess
Access Points

EmbeddedRewrite - Clipboard02.jpg

  1. 打开站点管理(Site Admin) -> URL重写(Url Rewrite) -> 安装(Setup)标签。你需要再次使用嵌入模式来进行此操作。
  2. 填写Htaccess路径。这是你嵌入模式的.htaccess文件的物理位置(/var/www/localhost/embedApp)。
  3. 填写Public路径。这是嵌入应用程序的路径,客户端将从web看到(如,/embedApp或 /)。

验证

URL Rewrite Tests

EmbeddedRewrite - Clipboard04.jpg

  1. 选择测试(Test)标签并查找嵌入的测试
  2. Gallery将进行测试,使你确信已对URL Rewrite模块进行了正确配置。

IIS ISAPI_Rewrite的配置[ ]

EmbeddedRewrite - Clipboard02.jpg

  1. 打开站点管理(Site Admin) -> URL重写(Url Rewrite) -> 安装(Setup)标签。你需要再次使用嵌入模式来进行此操作。
  2. 填写Public路径。这是嵌入应用程序的路径,客户端将从web看到(如,/embedApp或 /)。

PHP路径信息(PHP Path Info)的配置[ ]

无需配置嵌入模式。在修改规则时,你不需要处于嵌入模式中,因为Gallery将会对规则进行解析。