首页 > 解决方案 > 如何从 Piwigo 中删除 index.php 和 picture.php?

问题描述

https://example.com/index.php/categories

在 url index.php 上看起来不太好。如何从 url 中删除 index.php?

https://example.com/picture.php?/246/category/red-color-women-shoes

"picture.php?"- 想要删除友好的网址 /246/- 不确定它是什么。 /category/- 我认为它应该是类别名称,但显示“类别”

Piwigo 是用于网络的开源照片库软件 https://piwigo.org/

https://example.com/index.php/categories
https://example.com/picture.php?/246/category/red-color-women-shoes

$conf['question_mark_in_urls'] = false;
$conf['php_extension_in_urls'] = false; // this does not work
$conf['category_url_style'] = 'id-name';
$conf['picture_url_style'] = 'file';

网址应该是

https://example.com/categories

https://example.com/category-name/red-color-women-shoes

标签: php.htaccessurlconfiguration

解决方案


#TURN ON REWRITES
RewriteEngine on
RewriteBase /

#THEN OPTIONALLY MAKE IT www if they didnt enter it
RewriteCond %{HTTP_HOST} !^(www\.)?example\.com$ [NC]
RewriteRule ^(.*) https://www.example.com/$1 [R=301,L]

#Write index.any to /
RewriteRule ^index\.[a-z]{2,3}     /     [L,R=301]

#THEN REWRITE LOCATIONS
RewriteRule ^([0-9]+)/category/(.*)$    picture.php?id=$1&page_url=$2   [L]
#IF CATEGORY IS ALSO DYNAMIC THEN TRY THIS FOR REWRITE
RewriteRule ^([0-9]+)/(.*)/(.*)$    picture.php?id=$1&category=$2&page_url=$3   [L]

如果我正确理解您的问题..希望对您有所帮助


推荐阅读