Ok, I am totally stuck. I've spent hours on this today, and I can't figure out what is going on.

This is my .htaccess file:

RewriteEngine On
RewriteRule ^articles/([0-9]+)/([a-zA-Z0-9\-]+)$ /article.php?id=$1 [L]
RewriteRule ^articles/([0-9]+)/([0-9]+)/([a-zA-Z0-9\-]+)$ /article.php?id=$1&page=$2 [L]

RewriteRule ^topics/([0-9]+)/([a-zA-Z0-9\-]+)$ /topic.php?id=$1 [L]
RewriteRule ^topics/(.+)$ /sub-topic.php?topic=$1 [L]

RewriteRule ^authors/([0-9]+)/([a-zA-Z0-9\-]+)$ /author.php?id=$1 [L]

RewriteRule ^preview/([0-9]+)/([a-zA-Z0-9\-]+)$ /preview.php?id=$1 [L]


ErrorDocument 400 /error?id=badrequest
ErrorDocument 401 /error?id=authreq
ErrorDocument 403 /error?id=forbidden
ErrorDocument 404 /error?id=notfound
ErrorDocument 500 /error?id=server

the part i am struggling with is the last rewrite rule, for "preview." It is a copy of the rewrite rule for "articles," but it will NOT pass the variable.

So, for instance:
www.domain.com/articles/4/the-title is passing the $id (4) to article.php with no problems.

www.domain.com/preview/4/the-title is NOT.

I know it is not a problem with the code on the page. Can anyone point me in the right direction?

FYI, this is on a Godaddy server that has always worked with no problems in the past.

THanks!

Recommended Answers

All 3 Replies

RewriteEngine On
RewriteRule ^/?articles/([0-9]+)/([a-zA-Z0-9\-]+)$ /article.php?id=$1 [L]
RewriteRule ^/?articles/([0-9]+)/([0-9]+)/([a-zA-Z0-9\-]+)$ /article.php?id=$1&page=$2 [L]

RewriteRule ^/?topics/([0-9]+)/([a-zA-Z0-9\-]+)$ /topic.php?id=$1 [L]
RewriteRule ^/?topics/(.+)$ /sub-topic.php?topic=$1 [L]

RewriteRule ^/?authors/([0-9]+)/([a-zA-Z0-9\-]+)$ /author.php?id=$1 [L]
RewriteRule ^/?authors/([0-9]+)/([0-9]+)/([a-zA-Z0-9\-]+)$ /author.php?id=$1&page=$2 [L]

RewriteRule ^/?preview/([0-9]+)/([a-zA-Z0-9\-]+)$ /preview.php?id=$1 [L]
RewriteRule ^/?preview/([0-9]+)/([0-9]+)/([a-zA-Z0-9\-]+)$ /preview.php?id=$1&page=$2 [L]

ErrorDocument 400 /error?id=badrequest
ErrorDocument 401 /error?id=authreq
ErrorDocument 403 /error?id=forbidden
ErrorDocument 404 /error?id=notfound
ErrorDocument 500 /error?id=server

Thanks for the reply... didn't change anything though... hmm.

In case anyone is interested... i figured it out. AND, I have no idea why this works.

I had to change

RewriteRule ^preview/([0-9]+)/([a-zA-Z0-9\-]+)$ /preview.php?id=$1 [L]

to

RewriteRule ^previews/([0-9]+)/([a-zA-Z0-9\-]+)$ /preview.php?id=$1 [L]

(note the change -- ^preview to ^previews)

Then I just changed my url paths. I honestly have no idea why this made a difference... but, it did.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.