0
votes

I'm writing a few RewriteRules, and my most basic rewrite returns a 404 error. Here's my code:

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule s/(.*)/(.*)/$ /page.php?s=$2 [NC,L]
RewriteRule ^submit/$ submit.php [R,L]

# Options All -Indexes

<files .htaccess>
order allow,deny
deny from all
</files>

RewriteRule ^submit/$ submit.php [R,L] is where I'm having trouble. When I visit domain.com/submit/, my server returns a 404 error saying, "The requested URL /submit/ was not found on this server." It's like the server did not even look at my HTACCESS file. The other RewriteRules work perfectly.

Am I missing something?

1
Are you trying to rewrite /submit/ to submit.php, or redirect it there?Mike Rockétt
Try adding a leading slash to the substitution URL: from submit.php to /submit.phpkjetilh

1 Answers

1
votes

You may try this:

Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} !page\.php    [NC]
RewriteRule ^s/(.*)/(.*)/$ /page.php?s=$2 [NC,L]

RewriteCond %{REQUEST_URI} !submit\.php  [NC]
RewriteRule ^submit   submit.php         [R,L,NC]

That's it according to the information in the question.

Can't guess what's the first rule for as there are no URL examples to determine the pattern to be matched by the regex or the location of the script.

Something similar happens with the second rule because there is no way to confirm where the script (submit.php) is located as, again, there are no URL examples in the question.