CSCart Htaccess and directory php file - .htaccess

I have a cscart installation, with the classic htaccess.
<IfModule mod_rewrite.c>
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !\.(png|gif|ico|swf|jpe?g|js|css)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(win) [NC]
RewriteRule . index.php?sef_rewrite=1 [L,QSA]
</IfModule>
But, there is a folder with a php script I need to be accessible. Anytime I try to access that script, it shows CScart 404 page. But if change the script in the subdirectory to any other different file extension, it suddenly works.
cscart.com/folder/file.php doesn't work
cscart.com/folder/file.html works
Would any of you guys know how to turn htacess for that folder to run and show cscart 404 page?

Please check if under folder cscart.com/folder/ is present any .htaccess, this may be the issue
Some cs-cart folder have .htaccess with content
Order deny,allow
Deny from all
<Files ~ "\.(js|css|png|jpg|gz)$">
order allow,deny
allow from all
</Files>

remove this line:
RewriteBase /
Or correct the path when moving the CS-Cart to another directory.
RewriteBase /some/other/path

Related

How to make an internal redirect using a file .htaccess?

I have the urls
https://example.net/app/ref/user/u123456
https://example.net/app/ref/user/u123456/
Need redirect both url to https://example.net/app/ref/user/index.php?referral=u123456
How to do it with a file .htaccess? Unfortunately, I couldn't do it, so I'm asking for your help.
UPD: Now me .htaccess is in the same directory as index.php:
<IfModule mod_rewrite.c>
RewriteEngine on
</IfModule>
AddType application/x-httpd-php .html
<Files 403.shtml>
order allow,deny
allow from all
</Files>
With your shown samples please try following htaccess rules file. Please make sure you keep your .htaccess rules file in your root folder; alongside with your app folder.
Make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*/[^/]*/[^/]*)/([^/]*)/?$ $1/index.php?referral=$2 [QSA,L]

htaccess redirect to subfolder with url paramethers

I want to redirect every requests to my public/index.php file. i've tried
RewriteEngine On
RewriteRule ^(.*)$ public/index.php?url=$1
code that seems fine but its not working. my goal is change url form http://example.com/?url=user/profile/2 to http://example.com/user/profile/2.
my directory structure is
root
public
index.php
vendor
.htaccess
composer.json
To handle URLs like: http://example.com/user/profile/2 please try following Rules sets in your .htaccess file. Place your htaccess rules file into root directory. Please make sure to clear your browser cache before testing your URLs.
Options -MultiViews
RewriteEngine ON
RedirectBase /ApadanaCMS/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/(.*)/?$ public/index.php?url=$1/$2/$3 [L]
OR try following rules, please make sure either try above OR following rules at a time only.
Above will work for non-existing pages, to make it for any url(like you mentioned in your question) try:
Options -MultiViews
RewriteEngine ON
RedirectBase /ApadanaCMS/
RewriteCond %{REQUEST_FILENAME} !index\.php [NC]
RewriteRule ^([^/]*)/([^/]*)/(.*)/?$ public/index.php?url=$1/$2/$3 [L]
heres the solution:
uncoment (remove # ) mod_rewrite.so module in httpd.conf file in apache2 (in my case c:\Apache24\conf\httpd.conf) file. also change AllowOverride none to AllowOverride All in that file under DocumentRoot "${SRVROOT}/htdocs" section.
and this is .htaccess content
RewriteEngine on
RewriteRule ^(.*)$ public/index.php?url=$1 [QSA,L]
RewriteRule ^()$ public/index.php?url=$1 [QSA,L]
however if you need to get static files in your static directory add a new .htaccess file inside static directory with RewriteEngine off content

htaccess to block file but not dir

I have an htaccess problem with it blocking my directory because of the filesmatch flag.
I'm trying to block log files, but on my site also maintain a blog.
What happens is that if people come to site.com/blog they get a 403 error vs site.com/blog/ works just fine. Also some other functions within the blog fail as well because of this error.
I guess i'm not sure if the filesmatch is correct/working properly or how to fix this. htaccess files have never been my friend :p
Options +SymLinksIfOwnerMatch
# Prevent Directoy listing
Options -Indexes
# Prevent Direct Access to files
<FilesMatch ".(tpl|log|ini)">
Order allow,deny
Deny from all
</FilesMatch>
# SEO URL Settings
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^site.com [NC]
RewriteRule ^(.*)$ http://www.site.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
You need to escape your . in the <FilesMatch> container. It expects a regular expression and the . character means "any character that isn't a newline".
<FilesMatch "\.(tpl|log|ini)">
Order allow,deny
Deny from all
</FilesMatch>

htaccess rewriterule ignore index.html

I'm using CodeIgniter and .htaccess to rewrite the URLs but I want it to ignore index.html.
This is so we can upload an index.html at any time as this will be a temporary landing page. With a link through to the main site on the index.php.
This is what is currently in .htaccess and I have set the server's directory index to index.html index.php
RewriteEngine on
RewriteCond $1 !^(index\.html|index\.php|js|img|fonts|data|css|uploaded|mobile_devices|audioplayer|emails|robots\.txt|archive_blog)
RewriteRule ^(.*)$ /index.php/$1 [L]
Thanks for any help
that rather looks like you want to rewrite everything that does not really exist in your directory.
try this instead of your current RewriteCond:
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1
Instead of using RewriteCond to ignore the index.html file, you could instead restrict access to it directly through using the FilesMatch directive. FilesMatch accepts a regular expression which could filter based on file name (e.g., index.html) or any regular expression.
Blocking access to the index.html file
<FilesMatch "index\.html$">
Order allow,deny
</FilesMatch>
That would completely deny access to the index.html file. I will admit, that I do not know the negative effects this would have on search engine crawling.
To read more about the FilesMatch Directive see http://httpd.apache.org/docs/current/mod/core.html#filesmatch
As for the rest of the directories in that list you currently have, you could just lock down all directory access regardless of name. It would give you a little more coverage going forward.
Options -Indexes
To read more about the Options Directive see http://httpd.apache.org/docs/current/mod/core.html#options
In the end your new .htaccess file would look something like this:
# Protect specific files from access
<FilesMatch "index\.html$">
Order allow,deny
</FilesMatch>
# Hide directory listing for URL's mapping to a directory
Options -Indexes
# Follow all symbolic links in this directory
Options +FollowSymLinks
# General rewrite rules
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
Why don't you use the built in environment function?
You could create a 'maintenance' environment and set the base controller to whatever you want. Then you would just need to edit the index.php file to specify the environment you want.

HTaccess not rerouting [CodeIgniter]

I have an application that works great when using the full url: sitename.com/index.php/foo/ but when I use HTaccess to remove the index.php it doesn't seem to work as expected. No matter which page I access I only see the home page. The htaccess file is doing something because without that line I get a 404 error.
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|file-manager-files|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]
Thoughts?
On my test site everything works just fine. Is this a server setting that needs to be tweaked?
With Codeigniter you want something like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
If that is not working, check to make sure $config['index_page'] = ''; and your .htaccess directives are set right:
<Directory "/some/absolute/path/htdocs">
Options Indexes Includes FollowSymLinks MultiViews
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
I've done hundreds of Codeigniter installs on many OS configs and have always been able to get this to work, but I have had some issues occasionally where I had to get creative to get the index.php to disappear.
The RewriteCond is wrong. In first argument you have to use what to check. In example the requested URI, the script file name and so on. On the above example it looks like you try to compare $1 (dolar and one) to the right part of the Rewrite Condition :?

Resources