Author Topic: [REQ] Addition to "Search Engine Friendly URLs"  (Read 10218 times)

0 Members and 1 Guest are viewing this topic.

Offline marod0er

  • Full Member
  • ***
  • Posts: 199
    • View Profile
[REQ] Addition to "Search Engine Friendly URLs"
« on: July 19, 2005, 06:36:46 PM »
Hi,

Okay, this is going to be sound a bit troublesome, so concentrate when reading this  :P

Vano, are you reading this? Good.

I would like to start out by saying that this is an addition to the already well known:
Quote
[Mod] Search Engine Friendly URLs aka Short URLs
http://www.4homepages.de/forum/index.php?topic=6729.0
I have some additions and some questions.

First off: I've noticed that alot of people have asked for having the "name of the page/picture" in the URL. While I know this cannot be done, because of 4images working with number id's, I've thought about something else. It would be possible to edit .htaccess specifically for every category. Meaning, every category would have its own unique name. For example:

categories.php?cat_id=1 would maybe be named "Travel", so it would become http://www.site.com/travel instead of just http://www.site.com/cat1.htm

I tried editing the htaccess file, acquired in the http://www.4homepages.de/forum/index.php?topic=6729.0 thread by Chris, and this is what I edited. Instead of having this:
Quote
RewriteRule ^cat\.html$ categories.php?%{QUERY_STRING}
RewriteRule ^cat([0-9]+)\.([0-9]+)\.html$ categories.php?cat_id=$1&page=$2&%{QUERY_STRING}
RewriteRule ^cat([0-9]+)\.html$ categories.php?cat_id=$1&%{QUERY_STRING}
I would have:
Quote
RewriteRule ^travel\.([0-9]+)$ categories.php?cat_id=1&page=$2&%{QUERY_STRING}
RewriteRule ^travel$ categories.php?cat_id=1&%{QUERY_STRING}

RewriteRule ^flying\.([0-9]+)$ categories.php?cat_id=2&page=$2&%{QUERY_STRING}
RewriteRule ^flying$ categories.php?cat_id=2&%{QUERY_STRING}
-you get the idea... Making new lines, for each category AND changing the number of the category in the URL accordingly.

Now, I then thought of having URLs looking like this:
Code: [Select]
http://www.site.com/travel/2Instead of:
Code: [Select]
http://www.site.com/travel?page=2I guess this could be done (this is proven to be a better solution, SE wise, we all know that), but there's just one problem. Let's say we have the URL http://www.site.com/travel/2 and I want to look at, say, a picture on that page. The browser would request, fx, http://www.site.com/travel/2/img24.htm which would be an incorrect filepath.

Therefore I did some searching, and found this on webmasterworld:
http://www.webmasterworld.com/forum92/2811.htm
Quote
RewriteEngine on
# not to loop
RewriteCond %{REQUEST_FILENAME} !/css_folder/
#if doesn't exist
RewriteCond %{REQUEST_FILENAME} !-f
# redirect
RewriteRule ([^/.]+)\.css$ /css_folder/$1.css [L]

This code will drop any folder path information, and keep only the name of the css file. If that's not what you want, then try

RewriteRule ^(.+)\.css$ /css_folder/$1.css [L]
-Where the answer to why doing this, was:
Quote
What's the benefit of doing this?

-If you use "virtual dirs", such as http://example.com/home/house.html and reference images/styles relative (src="css_folder/style.css"), the browser would request http://example.com/home/css_folder/style.css.

This broken path is being rewritten to the exsisting path http://example.com/css_folder/style.css.

Now, my question is, how do I edit the .htaccess and the session.php files, to be able to do this (http://www.site.com/travel/4)

Hope it all makes sense.
Greetz: Lasse

Offline marod0er

  • Full Member
  • ***
  • Posts: 199
    • View Profile
Re: [REQ] Addition to "Search Engine Friendly URLs"
« Reply #1 on: July 21, 2005, 01:27:22 PM »
Uhm, any thoughts on this? Seems like something everybody in here could use...
Greetz: Lasse

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [REQ] Addition to "Search Engine Friendly URLs"
« Reply #2 on: July 22, 2005, 12:21:02 AM »
the problem is that 4images is using relative paths for the images, template images, etc, so even if u manage to get /4images/travel/2 url type, the relative paths will point into /4images/travel/2/ directory instead of /4images/

besides that using RewriteCond %{REQUEST_FILENAME} !-f might hit on the server perfomance.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline marod0er

  • Full Member
  • ***
  • Posts: 199
    • View Profile
Re: [REQ] Addition to "Search Engine Friendly URLs"
« Reply #3 on: July 22, 2005, 01:39:15 AM »
Hmm. Too bad  :(
Greetz: Lasse

Offline marod0er

  • Full Member
  • ***
  • Posts: 199
    • View Profile
Re: [REQ] Addition to "Search Engine Friendly URLs"
« Reply #4 on: July 26, 2005, 03:33:38 PM »
the problem is that 4images is using relative paths for the images, template images, etc, so even if u manage to get /4images/travel/2 url type, the relative paths will point into /4images/travel/2/ directory instead of /4images/

I understand that, but wouldn't that be solved by simply correcting every image path to: http://www.yoursite.com/ ?
Greetz: Lasse

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [REQ] Addition to "Search Engine Friendly URLs"
« Reply #5 on: July 27, 2005, 01:24:08 AM »
it could...maybe...
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)