Hello,
I have posted this topic in several other forums but no response so far, probably becuase it would require a lot of work. I want to change the base URI of my site to / and not index.php. I know how to do this in config.php, but then the URL rewrite module doesn't work properly. The module would have to be changed to not default to index.php. Has anyone ever tried this before? I don't have php programming skills, so when I opened the class files for the module I was way above my head. For those wondering why I would want to do this...it's much better from a search engine optimization point of view
Posts: 8601
just curious, which pages that you want indexed by search engines have index.php in the URL?
even when your base URI is main.php or index.php, you can use rewrite rules so your album and photo pages don't have that base URI in them (with mod_rewrite, not with pathinfo).
Posts: 324
The only page which uses it is the home page...when people hit my site via external links they hit http://andrewprokos.com/. However, when they begin to navigate around the site all the internal links on the breadcrumb and navbars link back to index.php as the home page. So now the search engines are indexing my site as both http://andrewprokos.com/ and as. It's much better to remove the index page altogether and have your internal links point to the domain name that the external links point to. You can do this by using a 301 redirect in your htaccess file, but the problem is that gallery's search results are output at index.php (or main.php) and the admin login block redirects back to inde.php as well. When I enable the 301 redirect code which redirects index.php--->/ then the search feature stops working as does login.
Posts: 8601
i'm not sure what all is involved in changing the base URI, but for the case you describe above maybe you could just edit modules/core/classes/GalleryUrlGenerator.class, function generateUrl(). at the end before 'return $url;' add:
$url = preg_replace('#/index.php(\?|$)#', '/', $url);
ie, rather than change how the URL is generated, just modify it at the end.
Posts: 324
Hi Mindless,
Thanks for the code. I tried it out tonight and it did exactly what I needed. The problem is that when I add the change it breaks several of my modules:
1) Photoframes disappear...I am using the PGtheme photoframes
2) The contact owner link in top nav returns an error page
3) I am unable to disable/uninstall modules
4) I am unable to logout
Do you know why that might be? I would like to keep the cahnge in place if I can get around these issues
Posts: 8601
hm, can you look at the URLs for those links and see what's wrong with them? (or post them here)
Posts: 324
1) Ok for the Contact Owner module link:
http://mysite.com/index.php?g2_view=core.UserAdmin&g2_subView=contactowner.Contact&g2_return=%2Fphotos%2Fnew-york%2F&g2_returnName=album
When I put the change in place the url results in a page not found, but only from links which use "http://andrewprokos.com"...the links which still use "http://andrewprokos.com/index.php" don't get the error. The only place where index.php is still referenced after I put your change into place is the search module. Oddly enough the search module continues to work even after your change.
2) Photo frames:
There is no URL here that I can give you..it looks like photoframes are generated using javascript:
<a onmouseover="pic1890.className='ImageFrame_image giThumbnail opacity6'" onmouseout="pic1890.className='ImageFrame_image giThumbnail opacity10'" href="photos/landscapes/">
I am not sure why changing the URL would affect the module
3) Admin logout link (You can't see this on my site as I have disabled users and removed the login block from my site completely. I login directly from the browser):
http://mysite.com/index.php?g2_controller=core.Logout&g2_return=%2Findex.php&g2_returnName=album
I can see why this might not work as it references index.php
4) Uninstall/disable modules:
This also uses javascript, which refers to index.php. Here is the install link code for the statistics module:
</td>
<td style="width: 150px;">
<span id="action-install-module-statistics" style="display: none;">
<a style="cursor: pointer;" onclick="performPluginAction('module', 'statistics', '/index.php?g2_view=core.PluginCallback&g2_pluginId=statistics&g2_pluginType=module&g2_command=install')">
install
</a>
Thanks, Andrew
Washington DC Photography
New York City Photography
Posts: 8601
duh, i think i'm removing ? from the URLs.. try this instead:
$url = preg_replace('#/index.php(\?|$)#', '/$1', $url);
Posts: 324
That did the trick! I'm so jealous...I wish I knew how to do it myself! Admin and photo frames are both working normally now. The only pages which continue to refer to index.php are the contact and search module pages. That's not a problem since I have both those pages disallowed in robots.txt so the bots should not follow them. Many thanks for solving the last of a long line of SE compatibility issues for me...or at least I hope it's the last. I will post a reference to this in all the other posts I made about this.
New York City pictures
Washington DC pictures
Posts: 2
I'm wondering how to do something similar - to remove the /main.php/ from the URL...
old: http://mysite.net/g2/main.php/v/album/item.jpg.html
new: http://mysite.net/g2/album/item.jpg.html
I've already removed the '/v', but can't seem to remove the main.php...
Posts: 32509
elipire
don't use PathInfo.
after installing the URL rewrite module, you had the choice between PathInfo and mod_rewrite. You chose PathInfo. When using PathInfo, you can't get rid of main.php/.
Uninstall the url rewrite module and install it again to have the choice again. Then choose mod_rewrite in the configuration view.
Posts: 4
I don't want to sound ignorant here, but I don't think I have much choice, but i'm interested also in cleaning up the URL however my limited understanding would be that changing the generate URL return value, to just remove the index.php would stop the whole thing working?
i.e. the following line '$url = preg_replace('#/index.php(\?|$)#', '/', $url);' So next when using <a href="{g->url .... It will return / or /? (after mindless's review of the above line) and as far as I can see this would cause an error, obviously I'm wrong as apparently it works, but is anyone, in a line or two able to tell me why?
Cheers
Posts: 324
No, removing the index.php does not stop the whole thing from working. What you get is urls with the dynamic string appended to the end, i.e.:
example.com/?g2_view= vs. example.com/index.php?g2_view=
Posts: 565
nonamescriptware.com
stork.esosoft.net
66.241.145.22 (apparently RBL clean)
United States - California - Upland - Esosoft Corporation
66.241.144.0/20
Would moderation please remove all this off-topic nonsense.
----best wishes, Robert
[postedit: my thanks;~)]
Posts: 32509
icpix
what's the point of always posting the RBL stuff? it's obvious that it's spam.
--------------
Doumentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage
Posts: 565
valiant---- I don't 'always'...
Deleting (what is obviously) spam does nothing except
perhaps sweep the issue under the metaphorical carpet.
Knocking out the hosts or administrations, if done
widely, would almost certainly do more than nothing;~)
The point about the 'apparently RBL clean' emphasizes
that we cannot rely on merely the RBLs to help keep
us all running. No one can do anything about this
spam except the hosts and administrations. As you
are querying the usefulness of the relevant host
blocking information I will desist. I thought it
was of more use than the information in the spam.
----best wishes, Robert
Posts: 32509
My point is that forum readers usually don't care.
They just don't want to see the spam. They don't take notice of the usefulness of your post.
I suggest you rather submit your findings to one of the black-lists. More people profit that way.
--------------
Doumentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage
Posts: 565
The blacklists have their own sources.
This sort of spam delivery bypasses blacklists.
I run my own lists for my server.
My concern is for excellence of this forum.
I will desist supplying host blocking information.
Your sig has a typo (Doumentation/Documentation).
----best wishes, Robert