I recently uploaded a website on OVH made with the CakePHP Framework.
The fact is that whenever I want to go on a prefixed route, like /admin, or a plugin route, like /plugin_name, it's just duplicate the route on the URL.
For example, I'm on /admin/users/add, I click on the link to go on the index admin ( /admin ), the URL will be /admin/users/add/admin. For every prefixed route.
I've put all my folders directly on /www.
Here are my different .htaccess files:
On the root:
SetEnv PHP_VER 5
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ /app/webroot/ [L]
RewriteRule (.*) /app/webroot/$1 [L]
</IfModule>
Into the app folder:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ /webroot/ [L]
RewriteRule (.*) /webroot/$1 [L]
</IfModule>
And into the webroot:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/$1 [QSA,L]
</IfModule>
Furthermore, That did the same with my CSS / JS declarations in the <head>, and I noticed that if I don't use the CakePHP HtmlHelper, it works. But I can't do that for all my links / forms.
Thanks.
Related
I now have a Laravel installation with the default folder structure.
In my root folder I have a .htaccess file like this one.
Options +FollowSymLinks
<IfModule mod_rewrite.c>
# RewriteEngine On
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteRule ^ index.php [L]
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
I have to install in a subfolder WordPress.
So I would like to access to my WP installation using the URL http://www.example.com/ and to Laravel with http://www.example.com/admin.
The thing I know it's that is an .htaccess trick, but, even if I tried many kind of rewrites, I'm not still able to achieve the desired result.
So, in your root .htaccess you should use the following:
RewriteEngine On
# Route any request begining with 'admin/' to laravel
RewriteRule ^admin/(.*)$ public/$1 [L]
# Anything else goes to Wordpress
RewriteRule ^(.*)$ wp/$1
And in your Laravel .htaccess add:
RewriteBase /admin
If you can't live with the trailing slash being mandatory you can try:
RewriteRule ^admin(/(.*))?$ public/$2 [L]
Try this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /your-subdirectory/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /your-subdirectory/index.php [L]
</IfModule>
# END WordPress
Hello I am new user in symfony please solve my issue
I am writing the into the .htacess file is
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /web/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>
Or
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# Explicitly disable rewriting for front controllers
RewriteRule ^app_dev.php - [L]
RewriteRule ^app.php - [L]
RewriteCond %{REQUEST_FILENAME} !-f
# Change below before deploying to production
#RewriteRule ^(.*)$ /app.php [QSA,L]
RewriteRule ^(.*)$ /app_dev.php [QSA,L]
</IfModule>
Both are also work into the home page but not in sub pages like
http://demo.co.uk/
but not this
http://demo.co.uk/app_dev.php/services
So how to remove 1app_dev.php1, I wanna just like this
I think you are mixing up the two environments.
app_dev.php is your development version, it shouldn't be a requirement to remove it as you can see it only in development.
app.php is your default environment, which is production. That should be the one which is hidden from the users.
Anyway, if you still want to do this, you have to replace the RewriteRule only. Try this .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /web/
RewriteCond %{REQUEST_FILENAME} !-f
# Change below before deploying to production
#RewriteRule ^(.*)$ app.php [QSA,L]
RewriteRule ^(.*)$ app_dev.php [QSA,L]
</IfModule>
I'm trying to install CakePHP in www.domain.com/demo/realestate I changed .htaccess in root, app,webroot with ref from cakebook, S.O. and other websites. Most of them produced either 500 error or shown a blank page or 404 error.
My .htaccess code in each of those files are:
--in root--
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /demo/realestate
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
--in app--
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
--in webroot--
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I also tried to delete all .htaccess and write Configure::write('App.baseUrl', env('SCRIPT_NAME')); in app/config/core.php as per a suggestion in documentation but then it started taking demo as controller name and realestate as function name.
I request you to guide me to set it up!
There is no need to change in htaccess if you want to install cakephp in www.domain.com/demo/realestate. Just copy all cakephp files and folders in realestate folder with default htaccess and it'll work.
I have this very critical issue of Wordpress messing up with my website's sub directories. Following is the very detailed info.
I have a wordpress installed on root . Unfortunately, I cannot move it to a folder.
I have 3 other custom PHP applications in following 3 respective directories
a. /client
b. /console
c. /order
Following are the .htaccess code for each of these directories
.htaccess code for /client folder
# This Directive will make Apache look first
# for "index_good.html" before looking for "index.html"
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^orders$ orders.php
RewriteRule ^profile$ profile.php
RewriteRule ^orders/pending$ orders.php?type=pending
RewriteRule ^orders/completed$ orders.php?type=completed
RewriteRule ^logincheck$ logincheck.php
RewriteRule ^login$ login.php
RewriteRule ^logout$ logout.php
RewriteRule ^ticket/open$ support-ticket-open.php
RewriteRule ^ticket/open/step/2$ support-ticket-open-2.php
RewriteRule ^order/view/(\w+)$ show-order-details.php?id=$1 [L]
.htaccess for /console folder
# This Directive will make Apache look first
# for "index_good.html" before looking for "index.html"
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^orders$ orders.php
RewriteRule ^services$ services.php
RewriteRule ^service/add$ add-service.php
RewriteRule ^coupons$ coupons.php
RewriteRule ^markups$ markups.php
RewriteRule ^markups/view/maincat$ markups.php?view=maincat
RewriteRule ^markups/view/markup$ markups.php?view=markup
RewriteRule ^markups/view/option$ markups.php?view=option
RewriteRule ^order/add/step/(\w+)$ add-order.php?step=$1
RewriteRule ^order/add$ add-order.php
RewriteRule ^client/add$ add-client.php
RewriteRule ^clients$ clients.php
RewriteRule ^logout$ logout.php
RewriteRule ^login$ login.php
RewriteRule ^ordering/service$ service-ordering.php
RewriteRule ^ordering/markup$ markup-ordering.php
RewriteRule ^setting/markup$ markup-setting.php
RewriteRule ^setting/general$ general-settings.php
RewriteRule ^tickets$ tickets.php
RewriteRule ^ticket/open$ open-ticket.php
RewriteRule ^order/view/(\w+)$ show-order-details.php?id=$1 [L]
RewriteRule ^client/orders/(\w+)$ orders.php?client_id=$1 [L]
RewriteRule ^ticket/update/([\w-]+)$ update-ticket.php?ticket_no=$1 [L]
.htaccess for order folder
# This Directive will make Apache look first
# for "index_good.html" before looking for "index.html"
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^order$ order.php
RewriteRule ^order/([^/\.]+)/$ order.php?service=$1
RewriteRule ^order/view/(\w+)$ show-order-details.php?id=$1 [L]
.htaccess for Wordpress
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Now the issue is that all /client & /console folder are properly accessible. But I have a folder called /server/php/ inside /order folder. This folder seems to be inaccessible and redirects to a Wordpress 404 page. I've been trying hard. But, everything is in vain. Please lemme know what the issue can be . Also, I cannot move the Wordpress to a /wp folder. So, please advice accordingly.
Thanks in advance!
I once had an issue like this, i had a cakephp app in a subdirectory that has wordpress ass root, edit your wordpress htaccess to look like this
#Action php /cgi-php52/php
#AddHandler php52 .php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/(order/server/php/|order/server/php/.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
This is basically telling it to ignore Rewrite condition for the url that point to folders client, console and order
I'm new using cakephp, and I'm trying to set Friendly URLs for my site, but I'm having problems.
I've already made all the steps that the cakephp 2.3 Book says, and my apache configuration says that the mod_rewrite is being executed.
And when I enter the main page of cake, it says that the URL rewriting is not configured, and when I want to acces to my web I need to go throught www.mysite.com/index.php/controller/function and of course, i want this: www.mysite.com/controller/function, and if I try this route, it says that is not found in my server (and I have the controller and function created).
This are my .htacces files:
root directory:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
App directory:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
Webroot directory:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
I resolved It. in the file /etc/apache2/sites-enabled/000-default the directory was pointing to /var/www and my cakephp directory was in /var/www/html/myapp/cakephp. I changed it and now its working! :)