RewriteRule to hide PHP vars in URL
RewriteRule to hide PHP vars in URL
am 25.10.2009 16:04:27 von Rob Gould
I'm trying to follow the RewriteRule docs to make it so that:
http://benchwarmersports.com/packages/super-bowl-xliv/1
can be entered into the web-browser, and it transforms into:
http://benchwarmersports.com/packages.php?title=super-bowl-x liv&eventid=1
The good news is that it does transform the url when I do this. The
bad news
is that it also attempts to transform all the links (including to JS
files
and images).
Can someone tell me what I'd need to modify to avoid this problem
with the
RewriteRule?
My .htaccess file presently looks like this:
Options +FollowSymlinks
RewriteEngine On
RewriteOptions MaxRedirects=10
RewriteBase /
RewriteRule ^packages/([^/]+)/([^/]+)$ /packages.php?title=
$1&eventid=$2 [NC]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: RewriteRule to hide PHP vars in URL
am 25.10.2009 17:26:47 von Ashley Sheridan
--=-eewrlhcg1YHjRJKPVu4/
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
On Sun, 2009-10-25 at 11:04 -0400, Rob Gould wrote:
> I'm trying to follow the RewriteRule docs to make it so that:
>
> http://benchwarmersports.com/packages/super-bowl-xliv/1
>
> can be entered into the web-browser, and it transforms into:
>
> http://benchwarmersports.com/packages.php?title=super-bowl-x liv&eventid=1
>
>
> The good news is that it does transform the url when I do this. The
> bad news
> is that it also attempts to transform all the links (including to JS
> files
> and images).
>
> Can someone tell me what I'd need to modify to avoid this problem
> with the
> RewriteRule?
>
>
> My .htaccess file presently looks like this:
>
>
> Options +FollowSymlinks
> RewriteEngine On
> RewriteOptions MaxRedirects=10
> RewriteBase /
>
> RewriteRule ^packages/([^/]+)/([^/]+)$ /packages.php?title=
> $1&eventid=$2 [NC]
>
>
>
>
>
>
It's because in your HTML the URL's to the JS and images are relative.
Changing them to absolute should fix the problem
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-eewrlhcg1YHjRJKPVu4/--
Re: RewriteRule to hide PHP vars in URL
am 25.10.2009 17:51:58 von Rob Gould
--Boundary_(ID_1R1/07QwfYSmodw57OpXXQ)
Content-type: text/plain; charset=us-ascii; format=flowed; delsp=yes
Content-transfer-encoding: 7BIT
Isn't there a way to tell the Rewrite rule to skip anything found in a
js or images subfolder?
On Oct 25, 2009, at 12:26 PM, Ashley Sheridan wrote:
> On Sun, 2009-10-25 at 11:04 -0400, Rob Gould wrote:
>>
>> I'm trying to follow the RewriteRule docs to make it so that:
>>
>> http://benchwarmersports.com/packages/super-bowl-xliv/1
>>
>> can be entered into the web-browser, and it transforms into:
>>
>> http://benchwarmersports.com/packages.php?title=super-bowl-x liv&eventid=1
>>
>>
>> The good news is that it does transform the url when I do this. The
>> bad news
>> is that it also attempts to transform all the links (including to JS
>> files
>> and images).
>>
>> Can someone tell me what I'd need to modify to avoid this problem
>> with the
>> RewriteRule?
>>
>>
>> My .htaccess file presently looks like this:
>>
>>
>> Options +FollowSymlinks
>> RewriteEngine On
>> RewriteOptions MaxRedirects=10
>> RewriteBase /
>>
>> RewriteRule ^packages/([^/]+)/([^/]+)$ /packages.php?title=
>> $1&eventid=$2 [NC]
>>
>>
>>
>>
>>
>>
>
> It's because in your HTML the URL's to the JS and images are
> relative. Changing them to absolute should fix the problem
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>
--Boundary_(ID_1R1/07QwfYSmodw57OpXXQ)--
Re: RewriteRule to hide PHP vars in URL
am 25.10.2009 18:01:11 von Ashley Sheridan
--=-8r5cmEVsf4zuqNCQ+zTq
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
On Sun, 2009-10-25 at 12:51 -0400, Rob Gould wrote:
> Isn't there a way to tell the Rewrite rule to skip anything found in a
> js or images subfolder?
>
>
> On Oct 25, 2009, at 12:26 PM, Ashley Sheridan wrote:
>
> > On Sun, 2009-10-25 at 11:04 -0400, Rob Gould wrote:
> >>
> >> I'm trying to follow the RewriteRule docs to make it so that:
> >>
> >> http://benchwarmersports.com/packages/super-bowl-xliv/1
> >>
> >> can be entered into the web-browser, and it transforms into:
> >>
> >> http://benchwarmersports.com/packages.php?title=super-bowl-x liv&eventid=1
> >>
> >>
> >> The good news is that it does transform the url when I do this. The
> >> bad news
> >> is that it also attempts to transform all the links (including to JS
> >> files
> >> and images).
> >>
> >> Can someone tell me what I'd need to modify to avoid this problem
> >> with the
> >> RewriteRule?
> >>
> >>
> >> My .htaccess file presently looks like this:
> >>
> >>
> >> Options +FollowSymlinks
> >> RewriteEngine On
> >> RewriteOptions MaxRedirects=10
> >> RewriteBase /
> >>
> >> RewriteRule ^packages/([^/]+)/([^/]+)$ /packages.php?title=
> >> $1&eventid=$2 [NC]
> >>
> >>
> >>
> >>
> >>
> >>
> >
> > It's because in your HTML the URL's to the JS and images are
> > relative. Changing them to absolute should fix the problem
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
>
The rewrite rule isn't doing that though. What it is doing, is
converting the URL you give to something else on the server. The browser
still thinks it it the URL you gave though, so when it finds an image
going to "images/image1.jpg" it looks for that relative to the current
page it thinks it is displaying, irrespective of what the server is
doing.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-8r5cmEVsf4zuqNCQ+zTq--
Re: RewriteRule to hide PHP vars in URL
am 25.10.2009 19:46:14 von daniel danon
--001636ed71ad13c2fb0476c6dcc5
Content-Type: text/plain; charset=UTF-8
As Ashley said, its the wrong way to approach this problem.
I suggest you read about "base href". ( )
it is a HTML tag.
On Sun, Oct 25, 2009 at 6:51 PM, Rob Gould wrote:
> Isn't there a way to tell the Rewrite rule to skip anything found in a js
> or images subfolder?
>
>
>
> On Oct 25, 2009, at 12:26 PM, Ashley Sheridan wrote:
>
> On Sun, 2009-10-25 at 11:04 -0400, Rob Gould wrote:
>>
>>>
>>> I'm trying to follow the RewriteRule docs to make it so that:
>>>
>>> http://benchwarmersports.com/packages/super-bowl-xliv/1
>>>
>>> can be entered into the web-browser, and it transforms into:
>>>
>>> http://benchwarmersports.com/packages.php?title=super-bowl-x liv&eventid=1
>>>
>>>
>>> The good news is that it does transform the url when I do this. The
>>> bad news
>>> is that it also attempts to transform all the links (including to JS
>>> files
>>> and images).
>>>
>>> Can someone tell me what I'd need to modify to avoid this problem
>>> with the
>>> RewriteRule?
>>>
>>>
>>> My .htaccess file presently looks like this:
>>>
>>>
>>> Options +FollowSymlinks
>>> RewriteEngine On
>>> RewriteOptions MaxRedirects=10
>>> RewriteBase /
>>>
>>> RewriteRule ^packages/([^/]+)/([^/]+)$ /packages.php?title=
>>> $1&eventid=$2 [NC]
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>> It's because in your HTML the URL's to the JS and images are relative.
>> Changing them to absolute should fix the problem
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>>
>>
>>
>
--
Use ROT26 for best security
--001636ed71ad13c2fb0476c6dcc5--
Re: RewriteRule to hide PHP vars in URL
am 26.10.2009 03:16:56 von kranthi
--00504501634b0fd2140476cd299d
Content-Type: text/plain; charset=ISO-8859-1
you have to type the relative path to your document root for every URI)
seems you are looking for
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#Rewrit eCond
--00504501634b0fd2140476cd299d--
Re: RewriteRule to hide PHP vars in URL
am 26.10.2009 10:00:05 von Ashley Sheridan
--=-TZcm06knGCU9ijyONnVl
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
On Mon, 2009-10-26 at 07:46 +0530, kranthi wrote:
>
> you have to type the relative path to your document root for every URI)
>
> seems you are looking for
> http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#Rewrit eCond
I don't think that will do what he wants. Consider the following two
examples:
http://www.example.com/docs/somedoc
http://www.example.com/
Now imagine there was a rewrite rule set up to take these URLs and
convert them into the following server-side:
http://www.example.com/index.php?doc=somedoc
http://www.example.com/index.php
The same index.php page is being used to serve up all the content, but
to the browser, one 'page' is located in the document root, the other
in /docs. Any relative URL's in the pages to images, CSS, Javascript,
etc will be treated as relative to where the browser thinks the page is,
not where the server does. Therefore, you either have to use the
tag or make all the URL's absolute. The tag method allows for
more flexibilty in the future, for example if you changed domain name
slightly.
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-TZcm06knGCU9ijyONnVl--