Page 1 of 1

[SOLVED]seo

Posted: Thu Sep 08, 2005 9:57 pm
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?

Posted: Thu Sep 08, 2005 10:05 pm
by anjanesh
What happens when you change the RewriteRule to

Code: Select all

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

Posted: Thu Sep 08, 2005 10:09 pm
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 :)

Posted: Thu Sep 08, 2005 10:47 pm
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

Posted: Thu Sep 08, 2005 11:20 pm
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

Posted: Thu Sep 08, 2005 11:25 pm
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

Posted: Thu Sep 08, 2005 11:28 pm
by josh
eh,

Code: Select all

RewriteRule dev/display/bash/([0-9]+) /dev/display/bash/display.php?bash=$1

Posted: Thu Sep 08, 2005 11:36 pm
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...

Posted: Thu Sep 08, 2005 11:56 pm
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.

Posted: Fri Sep 09, 2005 12:09 am
by feyd

Posted: Fri Sep 09, 2005 3:20 am
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.

Posted: Fri Sep 09, 2005 3:28 am
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

Posted: Fri Sep 09, 2005 11:29 am
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 :)