Welcome to WebmasterWorld Guest from 107.23.37.199

Forum Moderators: Ocean10000 & phranque

Message Too Old, No Replies

mod_rewrite frustration (of course)

     
5:36 am on Dec 2, 2003 (gmt 0)

New User

10+ Year Member

joined:Dec 2, 2003
posts:2
votes: 0


I want my users to be able to use a URL like:
[example.com...]
to access the page behind
[example.com...]

I have tried all of the following:


RewriteRule entry/(.+) entry.php?id=$1 [L]
RewriteRule /entry/(.+) /entry.php?id=$1 [L]
RewriteRule ^entry/(.+)$ entry.php?id=$1 [L]
RewriteRule ^/entry/(.+)$ /entry.php?id=$1 [L]
RewriteRule entry/(.*) entry.php?id=$1 [L]
RewriteRule /entry/(.*) /entry.php?id=$1 [L]
RewriteRule ^entry/(.*)$ entry.php?id=$1 [L]
RewriteRule ^/entry/(.*)$ /entry.php?id=$1 [L]
RewriteRule entry/([^/]+) entry.php?id=$1 [L]
RewriteRule /entry/([^/]+) /entry.php?id=$1 [L]
RewriteRule ^entry/([^/]+)$ entry.php?id=$1 [L]
RewriteRule ^/entry/([^/]+)$ /entry.php?id=$1 [L]
RewriteRule entry/([^/]*) entry.php?id=$1 [L]
RewriteRule /entry/([^/]*) /entry.php?id=$1 [L]
RewriteRule ^entry/([^/]*)$ entry.php?id=$1 [L]
RewriteRule ^/entry/([^/]*)$ /entry.php?id=$1 [L]

with no success. I've also tried using
QSA
and
NE
in the flags.

I can get:


RewriteRule ^entries.xml$ rss-entries.php [L]
RewriteRule ^page1.html$ page2.php [L]

to work, but not the rules with query strings in the substitution.

I have read a number of mod_rewrite threads on these boards and more tutorials on the web than I care to count, but just can't seem to figure this out. What am I doing wrong?

7:00 am on Dec 2, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:Sept 29, 2002
posts:356
votes: 0


No expert (sorry) but may be worth trying the rewrite rule generator at webmaster-toolkit dot com
7:47 am on Dec 2, 2003 (gmt 0)

New User

10+ Year Member

joined:Aug 23, 2003
posts:37
votes: 0


Hi there, I know this isn't exactly what you want, but it should give you a little better idea of the correct syntax. This will do just what you described, but it will only accept combos of alphanumeric characters and underscores. I'm not sure how you do a wild card, but I know everything else is right because I use a similar thing on my site.

^entry/([a-zA-Z0-9_]+)$ /entry.php?id=$1

7:41 pm on Dec 2, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


roosterboy,

> with no success

What do you mean by that? What happens when you test the code? Several of your rules are "close enough" to have worked.

Jim

8:27 pm on Dec 2, 2003 (gmt 0)

New User

10+ Year Member

joined:Dec 2, 2003
posts:2
votes: 0


Here's what happens:

I have some code as part of entry.php that spits out a friendly error message if there is no query string. When I use any of the rules I posted earlier, I get that error message. So apparently entry.php is getting hit, but without a query string.

Not only that, but my page is displayed without the appropriate CSS (i.e. unstyled). I have no idea what's up with that.

Any clues?

9:35 pm on Dec 2, 2003 (gmt 0)

New User

10+ Year Member

joined:Nov 25, 2003
posts:3
votes: 0


for your mod_rewrite, i've got the same problems, and haven't solved it yet.
one small idea would be to try to print_r($_GET) in your php file and look what happens.
if $_GET is empty, the regexp will be the problem.


Not only that, but my page is displayed without the appropriate CSS (i.e. unstyled). I have no idea what's up with that.

this is simple: if you refer to your stylesheet relatively, it won't work. you must refer it by the whole path: http://

flow:
<link rel=stylesheet href="myfile.css">

browser is looking in the folder for myfile.css, which is in the root directory.
as long as you call your file by
[example.com...]

it will work.

if you call the same file like this:
[example.com...]

the browser won't look for myfile.css in the root directory, but in /entry/john_doe/ , where it surely isn't, eh?

solution:

<link rel=stylesheet href="http://www.example.com/myfile.css">

good luck with the mod_rewrite! :)