[SOLVED]seo

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
blacksnday
Forum Contributor
Posts: 252
Joined: Sat Jul 30, 2005 6:11 am
Location: bfe Ohio :(

[SOLVED]seo

Post by blacksnday »

this isnt really php more so htaccess.

I am using

Code: Select all

RewriteEngine on
RewriteRule display/(.*)/(.*)$ /dev/display.php?$1=$2
to make my link /dev/display/bash/display.php?bash=6
to look like /dev/display/bash/6

however this has caused a huge problem.
Now all urls relating to the pages call from
/dev/display/bash/
instead of the actual folder.
Example is /dev/imgs/smileys/setone/smile.gif
Now shows as /dev/display/bash/imgs/smileys/setone/smile.gif

Which renders all links/images/css url/etc.. useless
Is there a way around this without me having to use full url paths for
everything that is linked?
Last edited by blacksnday on Thu Sep 08, 2005 11:56 pm, edited 1 time in total.
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

What happens when you change the RewriteRule to

Code: Select all

RewriteRule display/(.*)/([0-9]*)$ /dev/display.php?$1=$2
?
User avatar
blacksnday
Forum Contributor
Posts: 252
Joined: Sat Jul 30, 2005 6:11 am
Location: bfe Ohio :(

Post by blacksnday »

anjanesh wrote:What happens when you change the RewriteRule to

Code: Select all

RewriteRule display/(.*)/([0-9]*)$ /dev/display.php?$1=$2
?
same results.

If i change the image url to use
/dev/imgs/smileys/setone/smile.gif
instead of what I was using ./imgs/smileys/setone/smile.gif
all works fine again.

I guess I can just make a variable in my config file that directs what
directory everything is located in and then call it using something like
/$directory/imgs/smileys/setone/smile.gif
so that I can still maintain editable code :)
User avatar
blacksnday
Forum Contributor
Posts: 252
Joined: Sat Jul 30, 2005 6:11 am
Location: bfe Ohio :(

Post by blacksnday »

ok i know this problem but my mind is drawing a blank right now.

Using

Code: Select all

$directory  = 'dev';
to define the directory works
when using in situation like

Code: Select all

<link href='/$directory/style.css' type='text/css' rel='stylesheet'/>
I forget how to correctly use it when trying to pass to something like

Code: Select all

$html = preg_replace("#\[smile]#i", "<img src='/$directory/imgs/smileys/setone/smile.gif' border='0'>", $html);
as the above will not load the value
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

If you want

Code: Select all

to make my link /dev/display/bash/display.php?bash=6
to look like /dev/display/bash/6
use this:

Code: Select all

RewriteRule /dev/display/bash/([0-9]+) /dev/display/bash/display.php?bash=$1
The rewrite rule you posted in your OP is way to general
User avatar
blacksnday
Forum Contributor
Posts: 252
Joined: Sat Jul 30, 2005 6:11 am
Location: bfe Ohio :(

Post by blacksnday »

jshpro2 wrote:If you want

Code: Select all

to make my link /dev/display/bash/display.php?bash=6
to look like /dev/display/bash/6
use this:

Code: Select all

RewriteRule /dev/display/bash/([0-9]+) /dev/display/bash/display.php?bash=$1
The rewrite rule you posted in your OP is way to general
That causes Internal Server Error
Well, in root htaccess it doesnt, however it wont allow for the links to be valid
Last edited by blacksnday on Thu Sep 08, 2005 11:28 pm, edited 1 time in total.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

eh,

Code: Select all

RewriteRule dev/display/bash/([0-9]+) /dev/display/bash/display.php?bash=$1
User avatar
blacksnday
Forum Contributor
Posts: 252
Joined: Sat Jul 30, 2005 6:11 am
Location: bfe Ohio :(

Post by blacksnday »

changing it to

Code: Select all

RewriteRule display/bash/([0-9]+) /dev/display.php?bash=$1
works as the other examples didnt.

It still has same problem with urls using ./ calling from the displayed
url path instead of real path.

It's not a problem as soon as I can figure out how to pass a variable to
a string like this

Code: Select all

$html = preg_replace("#\[smile]#i", "<img src='/$directory/imgs/smileys/setone/smile.gif' border='0'>", $html);
If I use

Code: Select all

$html = preg_replace("#\[smile]#i", "<img src='/dev/imgs/smileys/setone/smile.gif' border='0'>", $html);
all is fine, but then creates havoc when needing to put code on different server/folder structure
hence why I rather use a variable :)
One I get that fixed then everything will be ok since I can then
bypass the Rewrite problem by using the $directory to define the
paths of images/templates/css/etc...
User avatar
blacksnday
Forum Contributor
Posts: 252
Joined: Sat Jul 30, 2005 6:11 am
Location: bfe Ohio :(

Post by blacksnday »

I got it working. though i think i need to make the
$directory a global?
Right now have it in my config but
needed to also have it in the function for the images.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

User avatar
phpdevuk
Forum Contributor
Posts: 220
Joined: Mon Jul 04, 2005 5:31 am
Location: UK
Contact:

Post by phpdevuk »

I found that adding <base href="http://www.somesite.com/" /> to the html head area in a header file worked for me, basically it tells the browser to load all images etc from this base url.
User avatar
blacksnday
Forum Contributor
Posts: 252
Joined: Sat Jul 30, 2005 6:11 am
Location: bfe Ohio :(

Post by blacksnday »

I also noticed that if i have the code installed on root level, then just
using the url starting with / instead of ./ it works just fine.

i will try the <base href="http://www.somesite.com/" /> on the code
that is in a subdirectory later.

Thanks :D
User avatar
blacksnday
Forum Contributor
Posts: 252
Joined: Sat Jul 30, 2005 6:11 am
Location: bfe Ohio :(

Post by blacksnday »

phpdevuk wrote:I found that adding <base href="http://www.somesite.com/" /> to the html head area in a header file worked for me, basically it tells the browser to load all images etc from this base url.
Just wanted to add the above works great and has actually
solved some other minor annoyances that I have been dragging myself to fix :)
Post Reply