Forum Moderators: coopster

Message Too Old, No Replies

Alternative to ForceType

When making Spider friendly URLs in PHP

         

geckofuel

11:48 am on Jul 13, 2003 (gmt 0)

10+ Year Member



Hi. Is anyone familiar with an alternative to using ForceType to make spider friendly URLS via an extensionless file?

Say I want my URLS to look like this:
[myserver.com...]

filename would be the php file.

Someone mentioned the following solution but it isn't passing the proper URI:

RewriteEngine on
RewriteCond %{REQUEST_URI}!filename\.php
RewriteRule ^filename(.*)$ \filename.php?uri=$1

With this, you've got two files: filename and filename.php When filename is requested, it rewrites to filename.php for parsing. The question I have is how you should go about preserving the entire URI "/var1/var2/var3" in a rewrite to filename.php.

killroy

11:54 am on Jul 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Wel first of all it should be
/filename.php (not \filename)

then, you could rewrite the vars into a proper?var1=val1&var2=val2 sort of string, but otherwise that looks ok.

SN

dmorison

11:56 am on Jul 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

At first glance, $1 should contain "/var1/var2". If it doesn't, what are you getting instead?

geckofuel

2:41 pm on Jul 13, 2003 (gmt 0)

10+ Year Member



Interestingly, when I do this:

RewriteEngine on
RewriteCond %{REQUEST_URI}!filename\.php
RewriteRule ^filename(.*)$ /filename.php?uri=test$

And echo out the $uri in the php file, I don't get "test" - I just get an empty string.

Any ideas?

killroy

3:24 pm on Jul 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There shouldnT' be a $ at the end

SN

DrDoc

4:02 pm on Jul 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RewriteEngine on
RewriteCond %{REQUEST_URI}!filename\.php
RewriteRule ^filename(.*)$ /filename.php?uri=$1

If the requested URL is:

[example.com...]

the $uri variable will contain "/test/blah/whatever"