How to remove index.php and picture.php from Piwigo? - php

https://example.com/index.php/categories
On url index.php it does not look good. How can I remove index.php from url?
https://example.com/picture.php?/246/category/red-color-women-shoes
"picture.php?" - want to remove for friendly url
/246/ - Not sure what it is.
/category/ - I think it should be category name but shows "category"
Piwigo is open source photo gallery software for the web
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';
Url should be
https://example.com/categories
and
https://example.com/category-name/red-color-women-shoes

#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]
If I understand your question right.. hope that helps

Related

htaccess redirect to subfolder, if URL contains string

I feel really sorry, cause I feel like this is a simple question and it was answered few times, but I can't solve my problem ;(
I have a folder structure like this:
restaurant (folder)
.htaccess
index.php
anotherfile.php
few_more_files.php
htaccess file in root directory contains this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !(test\.pdf|\.png)$ [NC]
RewriteRule ^(.+)$ index.php [QSA,L]
I need a way to implement logic:
if URL contains mydomain.com/restaurant/any_other_strings_here, I need to redirect to /restaurant/index.php file
What should I do? Thanks in advance!
You have to handle domain and url separatetly:
# Only redirect if domain = dmydomain.com
RewriteCond %{HTTP_HOST} ^mydomain\.com$
# Redirect only if url contains restaurant/any_other_strings_here
# L = last = End htaccess evaluation after this rule
# R=301 = Redirect with status 301
RewriteRule restaurant/any_other_strings_here$ /restaurant/index.php [L,R=301]
Probably "any_other_string" refers to something wildcardish, so this might be better for you:
RewriteRule restaurant/(.*)$ /restaurant/index.php [L,R=301]

How to change php urls on my website?

Is it possible to somehow change my website links from:
domain.com/category.php?tag=test
domain.com/section.php?tag=test
domain.com/news.php?tag=test
into this:
domain.com/category-test
domain.com/section-test
domain.com/news-test
Thanks and have a good day!
You can achieve this using .htaccess and mod_rewrite. You'll need to create a .htaccess file with the following contents:
RewriteEngine On
RewriteBase /
RewriteRule ^category-([^/]+)/?$ category.php?tag=$1
RewriteRule ^section-([^/]+)/?$ section.php?tag=$1
RewriteRule ^news-([^/]+)/?$ news.php?tag=$1
Now, accessing domain.com/category-test/ will take you to category.php?tag=test.
If you'd prefer to have slashes instead of dashes, you can use:
RewriteRule ^category/([^/]+)/?$ category.php?tag=$1
RewriteRule ^section/([^/]+)/?$ section.php?tag=$1
RewriteRule ^news/([^/]+)/?$ news.php?tag=$1
RewriteRule ^category-([a-zA-Z0-9]+)$ category.php?tag=$1 [NC,L]
RewriteRule ^section-([a-zA-Z0-9]+)$ section.php?tag=$1 [NC,L]
RewriteRule ^news-([a-zA-Z0-9]+)$ news.php?tag=$1 [NC,L]
In "category.php" file get the tag $_GET['tag'];

how to create Short Url in Mediawiki?

My mediawiki's localproject name is "wiki_test".and i use following code for localsettins.php file
$wgScriptPath = "/wiki_test";
$wgArticlePath = "/wiki/$1";
require_once("$IP/extensions/ShortUrl/ShortUrl.php"); //
and create one file in the root(means in my project folder) .htaccess file.and put following code in that
RewriteEngine On
# Short url for wiki pages
#RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/mediawiki_test/index.php/ [L]
# Redirect / to Main Page
RewriteRule ^/*$ %{DOCUMENT_ROOT}/mediawiki_test/index.php [L]
and try for short url but give error like"Object not found!". so plz give me idea........
If you are placing your .htaccess in mediawiki_test directory then this code should work:
RewriteEngine On
RewriteBase /mediawiki_test/
RewriteRule ^index\.php$ - [L]
RewriteRule ^ index.php [L]

Rewrite rules not working htaccess

I have the following htaccess rewrite rules
RewriteRule ^shows-watch/(.*).html?$ show.php?name=$1
RewriteRule ^shows-watch/(.*)/season-(.*).html?$ show.php?name=$1&season=$2
RewriteRule ^shows-watch/(.*)/season-(.*)/episode-(.*).html?$ show.php?name=$1&season=$2&episode=$3
Now the thing is, the first rewrite rule works just fine
RewriteRule ^shows-watch/(.*).html?$ show.php?name=$1
It's just when I try using the others, only name get variable is being passed and not
$_GET['season']
or
$_GET['episode']
i know it's most likely something simple I'm missing or have done, but I just can't seem to get it working.
Give this a try:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^shows-watch/([^/]+)/season-([^/]+)/episode-([^/]+).html?$ show.php?name=$1&season=$2&episode=$3 [QSA,NC,L]
RewriteRule ^shows-watch/([^/]+)/season-([^/]+).html?$ show.php?name=$1&season=$2 [QSA,NC,L]
RewriteRule ^shows-watch/([^.]+)\.html?$ show.php?name=$1 [QSA,NC,L]
The order is very important so they don't overlap you also need the L flag to stop when needed.
This assumes your .htaccess is on the root folder of your domain along with the show.php file and that you are accessing it like this:
domain.com/shows-watch/Show Name.html
domain.com/shows-watch/Show Name/season-1.html
domain.com/shows-watch/Show Name/season-1/episode-10.html
The first line gets all the links because it matches all the links.
Try reverse the order:
RewriteRule ^shows-watch/(.*)/season-(.*)/episode-(.*).html?$ show.php?name=$1&season=$2&episode=$3
RewriteRule ^shows-watch/(.*)/season-(.*).html?$ show.php?name=$1&season=$2
RewriteRule ^shows-watch/(.*).html?$ show.php?name=$1
Or you can exclude slashes like this:
RewriteRule ^shows-watch/([^/]*).html?$ show.php?name=$1
RewriteRule ^shows-watch/([^/]*)/season-([^/]*).html?$ show.php?name=$1&season=$2
RewriteRule ^shows-watch/([^/]*)/season-([^/]*)/episode-([^/]*).html?$ show.php?name=$1&season=$2&episode=$3

.htaccess hidden parameter before page name

I am trying to rewrite urls like:
http://www.domain.com/contact?language=en
http://www.domain.com/?language=en
to:
http://www.domain.com/en/contact
http://www.domain.com/en/
using:
RewriteRule ^([^/]*)/([^/]+)/?$ $2/index.php?language=$1 [QSA,L]
I'm not sure why this isnt working!?
EDIT
I changed the rule to:
RewriteRule ^([^/]*)/([^/]*)/?$ $2/?language=$1 [QSA,L]
Which does not give errors with the URL's like the old rule above it. However, it does not goto the directory specified
http://www.domain.com/en/contact <- stays at the / (root)
RewriteEngine On
RewriteBase /
RewriteRule ^(en|fr|de|nl)/(.*)$ /$2?language=$1 [QSA,L]

Categories