.htaccess Error 404 on index file - html

Good day,
I was wondering if you could help me.
I have a .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_METHOD} =POST
RewriteRule ^ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
## hide .php extension snippet
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L]
ErrorDocument 404 http://scytech.co.za/Page-Not-Found/404
When i try to open http://admin.scytech.co.za it give me an error 404 but when i try to open http://admin.scytech.co.za/index it works 100%Could you please help me?

try this...
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]

Related

Tradebox 404 - File Not Found Sorry! Cannot seem to find the page you were looking for

After I finished the my installation I got this error:
404 - File Not Found
Sorry! Cannot seem to find the page you were looking for.
I don’t know how to resolve this error. The .htaccess look like this:
# Disable directory browsing
Options All -Indexes
---------------------------------------------------------------------
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([\s\S]*)$ index.php/$1 [L,NC,QSA]
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
ServerSignature Off

removing .html with .htaccess gives 404 error

So I just figured out how to make my own custom 404 page and the 404 page works now.
I did all the .htaccess stuff for 404 page but now I am trying to remove the .html from the url.
I put in the code i found from the internet and i belive it worked, because now the .html is gone but i am getting a 404 error page. e.x domain.com/contact shows me my 404 error.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /error_404.html
ErrorDocument 404 /error_404.html
RemoveType x-mapp-php4 .html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)$ $1.html [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*\.html\ HTTP/
RewriteRule ^(.*)\.html$ /$1 [R=301,L]
The bottom part where "RewriteCond" starts is the code for the removal of .html.
Try using this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule .* $0.html
RewriteRule (.*) /error_404.html
ErrorDocument 404 /error_404.html
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.html
RewriteRule ^/?(.*)\.html$ /$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^/?(.*)$ /$1.html [L]
</IfModule>

Remove .html from url in apache2

I am trying to remove .html
so the site is www.example.com/login
login.html is located in /var/www/html/login.html
I created .htaccess in /var/www/html/.htaccess
And I put in:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
This doesn't seem to work. Can someone tell me what is wrong?
Try it this way.
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ $1.html [L]
Apparently you changed your question.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

Point image request to a higher folder thru htaccess

Is there any rule I can write to make all requests to my image folder point up one folder. I'm dealing with a lot of links so I don't want to put ../
Eg: http://hostingxtreme.com/ajax/images/logo.png.
Should become http://hostingxtreme.com/images/logo.png
Thanks
Here the code I'm using
Dosent seem to be working!
php_value register_long_arrays On
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteEngine On
RewriteRule ^/?ajax/images/logo.png$ /images/logo.png [L,R=301]
</IfModule>
In the htaccess file in your document root, add either:
Redirect 301 /ajax/images/logo.png /images/logo.png
Or if you need to use mod_rewrite:
RewriteEngine On
RewriteRule ^/?ajax/images/logo.png$ /images/logo.png [L,R=301]
I got it!
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (ajax/|ajax/.*/)images/(.*)
RewriteRule (ajax/|ajax/.*/)images/(.*) images/$2
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (ajax/|ajax/.*/)stylesheets/(.*)
RewriteRule (ajax/|ajax/.*/)stylesheets/(.*) stylesheets/$2

Exclude all Files from Rewrite (NGINX to APACHE Migration)

My URL structure is like
http://www.example.com/folder/index.php?dir=dir1
To be able to access it from
http://www.example.com/folder/dir1
and at the same time redirect the 1st URL to 2nd one, my htaccess (in 'folder') is
Options +FollowSymLinks
RewriteEngine On
RewriteBase /folder
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
RewriteCond %{QUERY_STRING} ^dir=(.*)$ [NC]
RewriteRule ^ %1? [L,R=301,NE]
RewriteRule ^(.+)/? index.php?dir=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*)$ index.php?dir=$1 [L,QSA]
The Redirect and Rewrite were working perfect until recently I switched from NGINX back to APACHE.The trouble is that it is now also rewriting file extensions which I don't want!How can I only apply it only to directories and exclude ALL files from it?
Figured it out! :)
Actually had to add
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} -d
before the first rewrite!
So the htaccess looks like:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /folder
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]
RewriteCond %{QUERY_STRING} ^dir=(.*)$ [NC]
RewriteRule ^ %1? [L,R=301,NE]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+)/? index.php?dir=$1 [L,QSA]