I am making new plugin for Oxid E-shop. In my metadata file, description, title, logo, works perfectly and I can see plugin in backend, but when I activate plugin, nothing in frontend is changed. Blocks aren't overwritten.
/modules/myModule/metadata.php
'blocks' => array(
array(
'template' => 'layout/footer.tpl',
'block' => 'footer_main',
'file' => '/views/blocks/layout/footer.tpl'
)
I have just simple example in footer for now.
/modules/myModule/views/blocks/layout/footer.tpl
[{block name="footer_main"}]
<div class="footer-base">Schuberth test !</div>
[{/block}]
Location of template that should be overwritten: /application/views/azure/tpl/layout/footer.tpl
it should actually work, at least with versions >= 4.8
Check if your block entry was saved in database table oxtplblocks.
Sometimes OXID does not update cached metadata after you added new entries to metadata.php, in this case try to increase module version.
Also check your file names for typos.
If everything is there and correct, you should post the full code and tell us your shop version.
Opening oxtplblocks table in database discovered me a bug, OXMODULE column has lenght 32 characters, and my module ID/directory name was longer, so rest of name was cut off.
I found on other source that module id shouldn't be longer than 20 characters.
Sometimes it happend that you need to clear the cache (tmp). this works for me most the time.
Please add .htaccess file to /source directory and copy this code.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^graphql/?$ widget.php?cl=graphql&skipSession=1 [QSA,NC,L]
RewriteCond %{REQUEST_URI} config\.inc\.php [NC]
RewriteRule ^config\.inc\.php index\.php [R=301,L]
RewriteCond %{REQUEST_URI} setup [NC]
RewriteRule ^setup(.*)$ Setup$1 [R=301,L]
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
RewriteCond %{REQUEST_URI} oxseo\.php$
RewriteCond %{QUERY_STRING} mod_rewrite_module_is=off
RewriteRule oxseo\.php$ oxseo.php?mod_rewrite_module_is=on [L]
RewriteCond %{REQUEST_URI} !(\/admin\/|\/Core\/|\/Application\/|\/export\/|\/modules\/|\/out\/|\/Setup\/|\/tmp\/|\/views\/)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !(\.html|\/|\.jpe?g|\.css|\.pdf|\.doc|\.gif|\.png|\.js|\.htc|\.svg)$ %{REQUEST_URI}/ [NC,R=301,L]
RewriteCond %{REQUEST_URI} !(\/admin\/|\/Core\/|\/Application\/|\/export\/|\/modules\/|\/out\/|\/Setup\/|\/tmp\/|\/views\/)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (\.html|\/)$ oxseo.php
RewriteCond %{REQUEST_URI} (\/out\/pictures\/generated\/)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (\.jpe?g|\.gif|\.png|\.svg)$ getimg.php [NC]
RewriteRule ^(vendor/) - [F,L,NC]
RewriteRule ^migration - [R=403,L]
</IfModule>
# disabling log file access from outside
<FilesMatch "(EXCEPTION_LOG\.txt|\.log|\.tpl|pkg\.rev|\.ini|pkg\.info|\.pem|composer\.json|composer\.lock|test_config\.yml)$">
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order allow,deny
Deny from all
</IfModule>
</FilesMatch>
# Prevent .ht* files from being sent to outside requests
<Files ~ "^\.ht">
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order allow,deny
Deny from all
</IfModule>
</Files>
Options -Indexes
DirectoryIndex index.php index.html
It should be good.
I was using Oxid v6.2. And it worked for v6.4 as well.
Related
A client has requested a website built and now that it has been built, they've requested it be hosted alongside their existing website but in a subdirectory (example.com/example/path).
What I'm dealing with now is figuring out the required apache rules to host this correctly. I've uploaded the entire project structure to that directory. Within the public directory (/example/path/public) I have the following .htaccess file (henceforth I'll refer to this as the Laravel .htaccess):
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteBase /example/path
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Serve Cached Page If Available...
RewriteCond %{REQUEST_URI} ^/?$
RewriteCond %{DOCUMENT_ROOT}/page-cache/pc__index__pc.html -f
RewriteRule .? page-cache/pc__index__pc.html [L]
RewriteCond %{DOCUMENT_ROOT}/page-cache%{REQUEST_URI}.html -f
RewriteRule . page-cache%{REQUEST_URI}.html [L]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
<FilesMatch ".(jpg|jpeg|png|gif|ico|svg|woff|woff2|ttf|eot|otf)$">
Header set Cache-Control "max-age=2628000, public"
</FilesMatch>
<FilesMatch ".(css|js)$">
Header set Cache-Control "max-age=86400, public"
</FilesMatch>
I have added the RewriteBase line based on me trying to find a solution to this.
Within the base .htaccess file (/example/path/.htaccess), I have the following:
<IfModule mod_alias.c>
Alias /example/path /home/www/<user>/html/example/path
<Directory "/home/www/<user>/html/example/path">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</IfModule>
The problem is however that this returns an internal server error. I've tried other potential solutions that don't use Alias that instead return 40X errors.
I need to be able to have the Laravel site fully working when a user visits example.com/example/path. I've tried numerous solutions over the past 90 minutes and none have worked.
What is the correct solution to my situation?
In public folder we have hosted 8 platforms and each platform's root directory we have this .htaccess configuration. hope this helps you.
<ifmodule mod_rewrite.c>
<ifmodule mod_negotiation.c>
Options -MultiViews
</ifmodule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]
RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/$1
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php
</ifmodule>
I did this recently too. My client had their Wordpress set to resolve at as the Document root (/var/www/html), but they also wanted their Laravel app "installed" in a subfolder of Wordpress and named "hq"
This however would be a security problem, because we only want Laravel's Public folder exposed, and not the application files. To solve this problem, I used the power of symbolic links!
The Laravel app was placed below the Document root at:
/var/www/laravel
I then exposed Laravel's public folder in the DocumentRoot with the command "ln -s symlinkLocation symbolic-link-name"
ln -s /var/www/laravel/public /var/www/html/hq
In the above line, you can see that "hq" is not an actual folder, but instead a symlink to /var/www/laravel/public
(which is where Laravel's index.php entry point is, the css, js etc)
Here is what the symbolic link looks like:
I also made a symbolic link to the storage folder:
ln -s /var/www/laravel/public/ /var/www/laravel/storage/app/public
Which accomplishes what "php artisan storage:link" accomplishes.
For reference, here is what my laravel .htaccess looks like:
The .htaccess in /var/www/laravel/public/.htaccess was
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Hope this helps
create a htaccess file in root directory of project
and add the following lines :
#disable directory browsing
Options -Indexes
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
#PROTECT ENV FILE
<Files .env>
order allow,deny
Deny from all
</Files>
#PROTECT htaccess FILE
<Files .htaccess>
order allow,deny
Deny from all
</Files>
I have a laravel application installed on a shared hosting package and I'm using https://github.com/JosephSilber/page-cache to cache pages.
The cached pages are stored in the following server folder /home/username/public_html/app_name/public/page-cache/article
The following code is in the .htaccess found in public folder
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Serve Cached Page If Available...
RewriteCond %{REQUEST_URI} ^/?$
RewriteCond %{DOCUMENT_ROOT}/public/page-cache/pc__index__pc.html -f
RewriteRule .? public/page-cache/pc__index__pc.html [L]
RewriteCond %{DOCUMENT_ROOT}/public/page-cache%{REQUEST_URI}.html -f
RewriteRule . public/page-cache%{REQUEST_URI}.html [L]
RewriteCond %{DOCUMENT_ROOT}/public/page-cache%{REQUEST_URI}.json -f
RewriteRule . public/page-cache%{REQUEST_URI}.json [L]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I have tried to debug the values of DOCUMENT_ROOT AND REQUEST_URI and I'm getting the following:
%{DOCUMENT_ROOT} = /home/username/public_html/app_name and %{REQUEST_URI} = /article/race-policing-and-the-universal-yearning-for-safety
With the above code in .htaccess i'm not managing to direct it to the cache pages but its going directly to the application even though the file exists.
e.g. /home/username/public_html/app_name/public/page-cache/article/race-policing-and-the-universal-yearning-for-safety.html
There is also the following .htaccess file in the app_name folder.
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/$1
#disable directory browsing
Options -Indexes
#PROTECT ENV FILE
<Files .env>
order allow,deny
Deny from all
</Files>
#PROTECT ENV FILE
<Files .htaccess>
order allow,deny
Deny from all
</Files>
I would appreciate if someone can help me identify the reason why the .htaccess is not loading the cache page when it exists. Stay safe guys :).
I have created a website on my localhost,
Inside htdocs I have added a folder 'sitename' this contains all files including .htaccess. This is working fine on my local, but when I am uploading it on server the its not working.
.htaccess code
Options +FollowSymlinks
RewriteEngine on
RewriteBase /sitename/
# redirect to .php-less link if requested directly
#RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
#RewriteRule ^ /sitename/%1 [R,L,NC]
ErrorDocument 404 /sitename/404
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/sitename/$1.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
What should be the replacement for 'sitename' while uploading on cpanel
public_html??
If you keep your scripts in a sub-folder (example: /public_html/sitename/ than below should work for you). However, if you keep your scripts directly in /public_html/ (example: /public_html/index.php) than replace RewriteBase /sitename/ with RewriteBase /
Options +FollowSymlinks
<IfModule mod_rewrite.c>
# let the PHP knows that the mod_rewrite module is ENABLED.
SetEnv HTTP_MOD_REWRITE On
RewriteEngine on
RewriteBase /sitename/
</IfModule>
#prevent direct access to certain file types
<FilesMatch "\.(htaccess|htpasswd|ini|log|sh|inc|bak|psd|DS_Store|project)$">
Order Allow,Deny
Deny from all
</FilesMatch>
ErrorDocument 404 /sitename/404.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/sitename/$1.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
Let us know if you get any error message - it would help.
I have seen other articles on the same issue. But none of the answers have solved my problem.
I am not using xampp or wamp but have setup php mysql apache seperately. Also I am using my own local domain for instance mytestsite.com.
My .htaccess file looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /TestCI/
# Canonicalize Codeigniter URLs
# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(HomeController(/index)?|index(\.php|html?)?)/?$ / [R=301,L]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [R=301,L]
# Enforce www
# If you have subdomains, you can add them to
# the list using the "|" (OR) regex operator
RewriteCond %{HTTP_HOST} !^(www|TestCI) [NC]
RewriteRule ^(.*)$ http://www.mytestsite.com/$1 [R=301,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>
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
</IfModule>
I have also made following changes in config.php
$config['base_url'] = 'http://mytestsite.com/TestCI/';
$config['index_page'] = '';
$config['uri_protocol'] = 'PATH_INFO'; //AUTO
I have also made following changes in apache2.conf
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
But when i try to access
http://mytestsite.com/TestCI/HomeController/
its showing 404 error but works correctly when using
http://mytestsite.com/TestCI/index.php/HomeController/
I have looked into several similar questions that have been reported solved, but none of the answers have worked for me. Is there anything else that should be done to remove index.php from the url. Kindly respond back. Help highly appreciated.
It may be the htaccess isn't being used.
Put a sytax error in the file. (Append something like hdtbf to the file)
If that doesn't give a 500 error you need to turn allow override all
In your main Apache config
http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride
Replace the following line of code in your .htaccess file
RewriteEngine On
RewriteBase /project/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Just put this code in your .htaccess :
RewriteEngine on
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Thankyou for helping me... Problem is solved.
I made the following changes in my apache2.conf file
<Directory /Absolute path to .htaccess folder
AllowOverride All
Require all granted
</Directory>
Also I removed the RewriteBase parameter in .htaccess file which is where the actual pbm was.
My current .htaccess file looks like
<IfModule mod_rewrite.c>
RewriteEngine On
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
I have also made changes in config.php where i changed $config['base_url'] to codeigniter root path
I'm trying to make clean urls with php and im getting some errors. Hope someone can help.
My .htaccess is as follows:
# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php
# this is the initialization
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /
# these are the rewrite conditions
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# and finally, the rewrite rules
RewriteRule ^([a-zA-Z0-9\-]+)/?$ /price/index.php?var1=$1 [L,QSA]
RewriteRule ^([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$ /price/index.php?var1=$1&var2=$2 [L,QSA]
RewriteRule ^([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$ /price/index.php?var1=$1&var2=$2&var3=$3 [L,QSA]
Actually I'm trying to make clean urls in the subfolder price/.
When I enter: mydomain.com/price/param1 it works perfect and it actually redirects me to
mydomain.com/price/index.php?var1=param1
But when I try to go forward with more variables is when I get the problem. When I try to access mydomain.com/price/param1/param2 I'm not redirected and a 404 error appears.
Any idea? Thanks in advance.
Try:
# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php
<IfModule mod_rewrite.c>
# This is the initialization
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /
# /price/var1/var2/var3
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^price/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$ /price/index.php?var1=$1&var2=$2&var3=$3 [L,QSA]
# /price/var1/var2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^price/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$ /price/index.php?var1=$1&var2=$2 [L,QSA]
# /price/var1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^price/([a-zA-Z0-9\-]+)/?$ /price/index.php?var1=$1 [L,QSA]
</IfModule>