[SOLVED] half-mod_rewrite after migration

xsoft

Joined: 2009-10-22
Posts: 4
Posted: Mon, 2009-11-02 22:41

Greeting,
Ive migrate to new hosting and everything works fine.

Now Ive attempt to change main.php -> /
to make default url:
http://foto.pocitac.com/
instead old http://foto.pocitac.com/main.php

I have followed steps at:
http://codex.gallery2.org/Gallery2:FAQ#Can_I_rename_main.php.3F
(ok? Ive stucked several times and I need to follow steps at: http://codex.gallery2.org/Gallery2:FAQ#I_enabled_mod_rewrite.2C_but_it.27s_not_working.2C_and_now_I_can.27t_get_back_to_disable_it_-_how_else_can_I_do_this.3F

So I do:
- disabled rewrite module ..done
- uninstall rewrite module ..done
- index.php renamed to index.phpG2
- main.php copy to index.php (and original renamed/saved as main.php-)
(at this point all work)
- mod rewrite enabled (download, set, test (that .htaccess can be writed) and install) ..done

Now where is a problem:
some url works, but not that, which ends on slash.
Eg:
http://foto.pocitac.com/v/Japonsko/ - does NOT work (404)
but http://foto.pocitac.com/v/Japonsko works

http://foto.pocitac.com/key/japonsko - works by default ..

Setting (rewrite module) is set to:
"v/%path%" ... its default, I dont change it, just enable
("v/%path%/" works with same result)

end of config.php:

Quote:
...

$gallery->setConfig('baseUri', 'http://foto.pocitac.com/');
define('GALLERY_MAIN_PHP', '');
?>

.htaccess:

Quote:
# BEGIN Url Rewrite section
# (Automatically generated. Do not edit this section)
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
RewriteCond %{REQUEST_URI} !/$
RewriteRule . - [L]

RewriteCond %{THE_REQUEST} /sitemap(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=sitemap.Sitemap [QSA,L]
RewriteCond %{THE_REQUEST} /d/([0-9]+)-([0-9]+)/([^/?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2&g2_fileName=%3 [QSA,L]
RewriteCond %{THE_REQUEST} /v/([^?]+)/slideshow\.html(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=slideshow.Slideshow&g2_path=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /c/view/([0-9]+)\.html(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=comment.ShowAllComments&g2_itemId=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /c/add/([0-9]+)\.html(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=comment.AddComment&g2_itemId=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /rss/([^\/\?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=rss.Render&g2_name=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /srss/([0-9]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=rss.SimpleRender&g2_itemId=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /key/([^?/]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=keyalbum.KeywordAlbum&g2_keyword=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /v/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_path=%1 [QSA,L]
</IfModule>

# END Url Rewrite section

# BEGIN Url Rewrite section
# (Automatically generated. Do not edit this section)
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
RewriteCond %{REQUEST_URI} !/$
RewriteRule . - [L]

RewriteCond %{THE_REQUEST} /sitemap(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=sitemap.Sitemap [QSA,L]
RewriteCond %{THE_REQUEST} /d/([0-9]+)-([0-9]+)/([^/?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2&g2_fileName=%3 [QSA,L]
RewriteCond %{THE_REQUEST} /v/([^?]+)/slideshow\.html(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=slideshow.Slideshow&g2_path=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /c/view/([0-9]+)\.html(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=comment.ShowAllComments&g2_itemId=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /c/add/([0-9]+)\.html(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=comment.AddComment&g2_itemId=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /rss/([^\/\?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=rss.Render&g2_name=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /srss/([0-9]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=rss.SimpleRender&g2_itemId=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /key/([^?/]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=keyalbum.KeywordAlbum&g2_keyword=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /v/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_path=%1 [QSA,L]
</IfModule>

# END Url Rewrite section

Quote:

phpinfo -> http://pocitac.com/x.php

Detaily posledního testu:

Gallery URL = http://foto.pocitac.com/
Verze Galerie = 2.3 jádro 1.3.0
API = Core 7.54, Module 3.9, Theme 2.6, Embed 1.5
Verze PHP = 5.2.10 apache2handler
Webový server = Apache
databáze = mysqli 5.0.67, lock.system=flock
Nástroje = Exif, Gd
Akcelerace = none, none
Operační systém = Linux php6 2.6.26-1-686 #1 SMP Fri Mar 13 18:08:45 UTC 2009 i686
Výchozí téma = matrix
gettext = umožněno
Lokalita = cs_CZ
Prohlížeč = Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.2 (KHTML, like Gecko) Chrome/4.0.222.3 Safari/532.2
Řádky v GalleryAccessMap tabulce = 18
Řádky v GalleryAccessSubscriberMap tabulce = 6315
Řádky v GalleryUser tabulce = 2
Řádky v GalleryItem tabulce = 6315
Řádky v GalleryAlbumItem tabulce = 158
Řádky v GalleryCacheMap tabulce = 0

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Mon, 2009-11-02 22:50

I don't know everything you want to do since it looks like you want to do about 15 different things.

To remove main.php from the URL, do this.

Edit config.php, near the bottom is a line that specifies baseUri. Edit that to just be: www.example.com instead of www.example.com/main.php

Then in .htaccess, at the top add this:
# Set the default handler.
DirectoryIndex main.php

____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here

 
xsoft

Joined: 2009-10-22
Posts: 4
Posted: Tue, 2009-11-03 09:40

Thanks, I tried this. Results:

.htaccess (top)

Quote:
# Set the default handler.
DirectoryIndex main.php

all links ends with error 500

Withount this setting works:
http://foto.pocitac.com
http://foto.pocitac.com/
http://foto.pocitac.com/v/Japonsko

but
http://foto.pocitac.com/v/Japonsko/
does NOT works. All links add "/" at the end. If anybody click on one album, then he will get 404 error.

I just wan one thing. To have mod_rewrite on (to obtain nice urls) without \main.php
(base album will then look like http://foto.pocitac.com/ and not http://foto.pocitac.com/main.php)
Btw, tutorial (about rename main.php in FAQ) dont mention about reactivatin rewrite module. But its possible, right?

.htaccess not looks like this:

Quote:
# Set the default handler.
# DirectoryIndex main.php

# BEGIN Url Rewrite section
# (Automatically generated. Do not edit this section)
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
RewriteCond %{REQUEST_URI} !/$
RewriteRule . - [L]

RewriteCond %{THE_REQUEST} /sitemap(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=sitemap.Sitemap [QSA,L]
RewriteCond %{THE_REQUEST} /d/([0-9]+)-([0-9]+)/([^/?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2&g2_fileName=%3 [QSA,L]
RewriteCond %{THE_REQUEST} /v/([^?]+)/slideshow\.html(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=slideshow.Slideshow&g2_path=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /c/view/([0-9]+)\.html(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=comment.ShowAllComments&g2_itemId=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /c/add/([0-9]+)\.html(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=comment.AddComment&g2_itemId=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /rss/([^\/\?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=rss.Render&g2_name=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /srss/([0-9]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=rss.SimpleRender&g2_itemId=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /key/([^?/]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_view=keyalbum.KeywordAlbum&g2_keyword=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /v/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/$
RewriteRule . /?g2_path=%1 [QSA,L]
</IfModule>

# END Url Rewrite section

config.php

Quote:
@ini_set('display_errors', 0);
$gallery->setConfig('setup.password', '******');
$gallery->setConfig('data.gallery.base', '/mnt/swraid/data/p/pocitac.com/foto/foto/');
$storeConfig['type'] = 'mysqli';
$storeConfig['hostname'] = 'localhost';
$storeConfig['database'] = 'foto_pocitac_com';
$storeConfig['username'] = 'foto.pocitac.com';
$storeConfig['password'] = '**********';
$storeConfig['schema'] = '';
$storeConfig['tablePrefix'] = 'g2_';
$storeConfig['columnPrefix'] = 'g_';
$storeConfig['usePersistentConnections'] = false;
$gallery->setConfig('storage.config', $storeConfig);
$gallery->setDebug(false);
$gallery->setProfile(false);
$gallery->setConfig('mode.maintenance', false);
$gallery->setConfig('mode.embed.only', false);
$gallery->setConfig('allowSessionAccess', false);
$gallery->setConfig('galleryBaseUrl', '');

$gallery->setConfig('baseUri', 'http://foto.pocitac.com');
define('GALLERY_MAIN_PHP', '')
;

 
xsoft

Joined: 2009-10-22
Posts: 4
Posted: Tue, 2009-11-03 14:14

Fixed.
Manual .htaccess edit to "force index.php"

Thanks
//SOLVED

Quote:
# Set the default handler.
# DirectoryIndex main.php

# BEGIN Url Rewrite section
# (Automatically generated. Do not edit this section)
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . - [L]

RewriteCond %{THE_REQUEST} /sitemap(\?.|\ .)
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?g2_view=sitemap.Sitemap [QSA,L]
RewriteCond %{THE_REQUEST} /d/([0-9]+)-([0-9]+)/([^/?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2&g2_fileName=%3 [QSA,L]
RewriteCond %{THE_REQUEST} /v/([^?]+)/slideshow\.html(\?.|\ .)
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?g2_view=slideshow.Slideshow&g2_path=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /c/view/([0-9]+)\.html(\?.|\ .)
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?g2_view=comment.ShowAllComments&g2_itemId=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /c/add/([0-9]+)\.html(\?.|\ .)
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?g2_view=comment.AddComment&g2_itemId=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /rss/([^\/\?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?g2_view=rss.Render&g2_name=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /srss/([0-9]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?g2_view=rss.SimpleRender&g2_itemId=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /key/([^?/]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?g2_view=keyalbum.KeywordAlbum&g2_keyword=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /v/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/index\.php$
RewriteRule . /index.php?g2_path=%1 [QSA,L]
</IfModule>

# END Url Rewrite section