Username
Forgot password?
Welcome to our site!
Or Join with FTTF

RewriteRule's seem to have no effect.

0

1325 views
I've got .htaccess working properly on my server.

If I use this (not real, just for testing) code, all page will show the ask form page:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?a=askform [L]
However when I only use the included rules (from RewriteRules.txt) subpages still 404.

I have RewriteEngine On, and all the rules. Any suggestions on things I should try to get this to work?
 
asked March 22, 2011 at 4:19 PM

 US

6 Answers

0
Best answer
 
I got it to work by removing the slashes at the beginning of each url.

This is my htaccess now:
RewriteEngine On

RewriteRule ^questions([\/]{0,1})$ index.php?a=viewquestions
RewriteRule ^questions/page([0-9]+)\.html index.php?a=viewquestions&pageID=$1
RewriteRule ^questions/([0-9]+)/(.*) index.php?a=viewquestion&qid=$1&urltext=$2
RewriteRule ^q([0-9]+)/(.*) index.php?a=viewquestion&qid=$1&urltext=$2
RewriteRule ^ask([\/]{0,1})$ index.php?a=askform
RewriteRule ^voted([\/]{0,1})$ index.php?a=viewquestions&cond=voted
RewriteRule ^voted/page([0-9]+)\.htm([l]{0,1})$ index.php?a=viewquestions&cond=voted&pageID=$1
RewriteRule ^active([\/]{0,1})$ index.php?a=viewquestions&cond=active
RewriteRule ^active/page([0-9]+)\.htm([l]{0,1})$ index.php?a=viewquestions&cond=active&pageID=$1
RewriteRule ^unanswered([\/]{0,1})$ index.php?a=unanswered
RewriteRule ^unanswered/noanswers([\/]{0,1})$ index.php?a=unanswered&cond=noanswer
RewriteRule ^unanswered/noanswers/page([0-9]+)\.html$ index.php?a=unanswered&cond=noanswer&pageID=$1
RewriteRule ^unanswered/tagged/([^\/]*)([\/]{0,1})$ index.php?a=unanswered&cond=tagged&tags=$1
RewriteRule ^unanswered/tagged/([^\/]*)/page([0-9]+)\.html$ index.php?a=unanswered&cond=tagged&tags=$1&pageID=$2
RewriteRule ^unanswered/page([0-9]+)\.html$ index.php?a=unanswered&pageID=$1
RewriteRule ^tags([\/]{0,1})$ index.php?a=viewqtags
RewriteRule ^tags/page([0-9]+)\.htm([l]{0,1})$ index.php?a=viewqtags&pageID=$1
RewriteRule ^tags/name([\/]{0,1})$ index.php?a=viewqtags&cond=name
RewriteRule ^tags/recent([\/]{0,1})$ index.php?a=viewqtags&cond=recent
RewriteRule ^tags/popular([\/]{0,1})$ index.php?a=viewqtags&cond=popular
RewriteRule ^tagged/(.*)/$ index.php?a=tagged&tags=$1
RewriteRule ^tagged/(.*)/page([0-9]+)\.html$ index.php?a=tagged&tags=$1&pageID=$2
RewriteRule ^vote/([0-9]+)/(up|down)$ index.php?a=vote&resid=$1&res=q&type=$2
RewriteRule ^ansvote/([0-9]+)/(up|down)$ index.php?a=vote&resid=$1&res=a&type=$2
RewriteRule ^accept/([0-9]+)$ index.php?a=accept&aid=$1
RewriteRule ^users/([0-9]+)/(.*) index.php?a=userinfo&uid=$1&username=$2
RewriteRule ^register index.php?a=register
RewriteRule ^([a-zA-Z\-]+)/page([0-9]+)\.html$ index.php?a=$1&pageID=$2
RewriteRule ^aa/([0-9]+)/([a-f0-9]+)$ index.php?a=activate&eid=$1&hash=$2
RewriteRule ^([a-zA-Z\-]+)/$ index.php?a=$1
RewriteRule ^search/(m|r)/(.*)/page([0-9]+)\.html$ index.php?a=search&ord=$1&q=$2&pageID=$3
flag
answered March 23, 2011 at 10:55 AM
This is interesting. I don't understand why the slashes were a problem but I have a feeling that even though it works for you now, the rewrites to index.php without the flash may cause problems with some of the urls. For example if you are on the page like /unanswered/noanswers/ then the rewrite will point to /unanswered/noanswers/index.php and not the the /index.php like it should. Just be aware of this and let me know if you run into this type of problem.
flag
Mar 23 '11 at 11:04
0
 
I have to test this more. I am using Apache on my home PC where I develop this, and everything works fine.
So, what happends when you submit the answer - you see the 404 page? This is strange because answer is submitted without any rewrite rules, the form is submitted via a POST.

Do you mean that after the answer is submitted then it redirects you to 404? That would be a different issue.
The way answer form works is it submits to server via ajax (XHR) then the response json object contains the html of the answer and it just appends the answer to the page, so there is no page reload.


flag
answered March 22, 2011 at 6:11 PM
0
 
OK, I think you are talking about the ask form. Do you mean that the whole link to 'Ask question" does not work for you?

Or do you see the "Ask" form but just having problem when submitting the new question?


flag
answered March 22, 2011 at 6:14 PM
Pages : 1 | 2 >

Your answer

Join with account you already have

FTTF

Preview

Alert