I have this directories structure on my server:
site.com/www/index.php
site.com/www/api/Slim
site.com/www/api/index.php
I want configure Slim for use as rest-api interface in 'api' folder. How can i configure htaccess in api folder for it?
Note. in www/ i have other htaccess and index.php for my project, i think this should not prevent. htaccess in www folder:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ index.php
You need to set your RewriteBase to folder where Slim application is located.
RewriteEngine On
RewriteBase /api/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
This one is the I am using.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
Related
I try to redirect url from
http://localhost/manual/$
to
http://localhost/manual/index.php?type=post&post=$
My file .htaccess is
RewriteEngine On
RewriteBase /manual/
RewriteCond %{REQUEST_FILENAME} !-f # Existing File
RewriteCond %{REQUEST_FILENAME} !-d # Existing Directory
RewriteRule . /manual/index.php? [L]
RewriteRule ^([^/]*)\/$ type=post&post=$1 [L]
But nor working whats wrong, help, sorry if duplicate because I still not understand to create htaccess.
You can use the following rule in /manual/.htaccess :
RewriteEngine on
RewriteBase /manual/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?type=post&post=$1 [L]
My url is http://example.com/product/Braided/table-fan
And i want to rewrite like this http://example.com/Braided/table-fan
where product is my php file.
Current rules:
Options +MultiViews +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^([0-9a-zA-Z]+)/([0-9a-zA-Z]+)/([0-9a-zA-Z]+)$ product/$1/$2/$3
RewriteRule ^([0-9a-zA-Z]+)/([0-9a-zA-Z]+)$ product.php?uname=$1&pid$2
Try and use this in your root .htaccess:
RewriteEngine On
RewriteRule ^$ product/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ product/$1
This should remove product from your URL and leave you with: http://example.com/Braided/table-fan.
Make sure you clear your cache before testing this.
How do I redirect to the "backend" or "frontend" directory using htaccess in the following project structure?:
I tried this code in .htaccess but it doesn't work:
<IfModule mod_rewrite.c>
Options -Indexes
RewriteEngine on
# Change '/myproject/' if directory is renamed
RewriteBase /myproject/
# Change the '/myproject/' portion of the condition if directory is renamed
RewriteCond %{REQUEST_URI} ^/myproject/backend/(.+)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ backend/index.php?url=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ frontend/index.php?url=$1 [QSA,L]
</IfModule>
This is my project structure:
myproject/
frontend/
backend/
common/
upload/
.htaccess
Please help me.
I am using the following code in the parent directory to redirect all non-existing directories to a landing page. The issue is that I still wish for 404 errors to occur in sub-directories such as admin,clients,images.... Is it possible to apply the following to only directories in the parent directory and not follow through to subdirectories?
RewriteEngine On
RewriteBase /
#Redirect For variables.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ landing.php?local=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/(.+)$
RewriteRule ^(.*)/? landing.php?local=$1 [QSA,L]
Any help on this matter is greatly appreciated.
You can use:
RewriteEngine On
RewriteBase /
#Redirect For variables.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ landing.php?local=$1 [QSA,L]
^([^/]+)/?$ will match a URI in root dir only. There is no need for 2nd rule.
I have site where
site.com/index.php?page=test (include file test.php from pages folder into index.php)
is replaced by site.com/test
Goal:
If I go to site.com/index.php?page=forum/new_enrty
I want ot make url site.com/forum/new-entry
Problem:
if I open site.com/forum/new-entry it directs me to forum directory to new-entry file directly and not include new-entry into index.php
So far I got this:
<IfModule mod_rewrite.c>
RewriteEngine on
#RewriteBase /cms/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^ index.php [L]
</IfModule>
Replace your code with this:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+?)/?$ index.php?page=$1 [L,QSA]
Try this one:
RewriteRule ^([^/]*)$ /index.php?page=$1 [L]