Pregunta

I have the below code in .htaccess

ErrorDocument 400 /abc/404

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^/ - [S=2]
    RewriteRule ^abc/(.*)/(.*)$ index.php?aa=$1&bb=$2 [NE,L,QSA]
    RewriteRule ^abc/(.*)$ index.php?aa=$1 [NE,L,QSA]

but I am getting the below error whenever i pass a wrong url

Not Found

The requested URL /abc/[S=2] was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

if i remove the line RewriteRule ^/ - [S=2] then I am getting the below error

Not Found

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

When I try http://example.com/abcd/ I want .htaccess to redirect to http://example.com/abc/404 which is a page

what mistake am I doing. Please help me.

thanks in advance

¿Fue útil?

Solución

Ok replace your code with this code:

ErrorDocument 404 /abc/404

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^abc/([^/]+)/([^/]+)/?$ /index.php?aa=$1&bb=$2 [NE,L,QSA]

RewriteRule ^abc/([^/]+)/?$ /index.php?aa=$1 [NE,L,QSA]
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top