I'm running a PHP app on the Heroku cedar stack. Is there a way to set up URL rewrite rules? I had hoped to do this in .htaccess files, but only access control directives are recognized in this.
I see that the Ruby advice is to use rake rewrite, but what needs to happen for a PHP app have URL rewrite configuration on Heroku?
You can use a normal .htaccess file with PHP on Heroku. Simply create a .htaccess file with the re-write conditions, similar to this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
This example lifted from WordPress. I believe all urls now redirect to /index.php. Example here: https://github.com/catsby/php-heroku-htaccess and app here: http://php-heroku-htaccess.herokuapp.com/something
So to partially answer my own question and continue what I alluded to in the comments, here's the difference between a Mac and a heroku .htaccess file that I needed to make:
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/$ $1/$2?arg=$3 #Mac
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/$ $1/$2.php?arg=$3 #heroku
This is more of a workaround than a solution. I believe the apache versions are different, but in the end I just capitulated on debugging this further and use a .htaccess file with two sections in it that I comment/uncomment.
Related
I have gotten a live chat system written in codeigniter, and I want to integrate my WebSite, which is written in Cakephp him.
I installed the "/ livechat" folder webroot, I modified the livechat file / application / config / config.php and I put :
$config['base_url'] = 'http://exemple.com/livechat/';
Then I modified the .htaccess file in the folder "/livechat" :
RewriteEngine On
RewriteBase /livechat
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1
But when I run the live chat with the address "http://exemple.com/livechat/" I get an error: 404 Page Not Found
Can someone help me please?
thank you in advance
i have downloaded recently cajax, but I don’t undesrtand how to install.
I have this folder:
Codeigniter/
application/
....
system/
....
I have copied all file in the folder Codeigniter
that:
Codeigniter/
cjax/
...
ajax.php
ajaxfw.php
system/
...
and I written localhost/codeigniter/testing.php?test/test
and result 404 error not found. Please help me with installation I need this framework.
this is my .htaccess if need to change:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Thank you!
Install/Download
http://cjax.sourceforge.net/docs/installing.php
Here are the steps to get the framework installed on your site, or test installation:
1. Download the latest stable release
2. Place the contents of the zip on the root of the site merging it with your current site.
So you'd end up with your current structure plus:
/
cjax/
controllers/
ajax.php
testing.php
You are set. Now lets test...
Testing your Cjax Installation
For security reasons you cannot access ajax.php directly on your browser, so we'll use testing.php to use.
Go onto your browser and type in the url for your site, plus testing.php?test/test, eg: http://yoursite.com/testing.php?test/test
If you see the text "Ajax View..." on your browser, that means you have successfully installed and tested the ajax framework.
You may find the text in file controllers/test.php in function test(). If your installation was successful you may delete file testing.php.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?ajax\/(.*)$ /ajax.php?$1 [NC,QSA,L]
RewriteCond $1 !^(index\.php|assets|robots\.txt|ajax)
RewriteRule ^(.*)$ index.php?/$1 [L]
This worked for me.
For those getting the error "Invalid Function" when clicking "View: test2" - check the URL you land on. In my case (using codeigniter), the code in test.php was missing the initial "/" so that it searches in the current directory instead of the root for ajax.php. Change the last line in /views/test.php
View: <a href='ajax.php?test/test2'>test2</a>
to
View: <a href='/ajax.php?test/test2'>test2</a>
Hope this helps!
Here is the solution to this problem.
You are not taking into account that Cjax is not exclusive to CodeIgniter. There are two different installation instructions, one Cjax universal code base that can be used on any application or website, then there is one version that integrates into CodeIgniter that is the one you are using, though you are following the instructions for the wrong installation.
There are documentations exclusive for Cjax for CodeIgniter, within CodeIgniter's wiki: https://github.com/bcit-ci/CodeIgniter/wiki/ajax-framework-for-codeigniter
Also, some good news: The new version of Cjax, 5.9 is the universal package, but has support built-in for CodeIgniter. This means that from there on, the installation instructions should be on the same place, or should be similar.
I am still new to magento but I have been slowly making progress on replicating the production environment to a sandbox environment.
The issue I am currently running into is that when I go to my site I get a long url rather than a short optimized url. I am guessing it is a configuration setting that I need to change as well as, I went through and had to add index.php to the url string for it to work properly.
What I want to be able to do is use a short url such as /category/page.html rather than catalog/category/view/s/power-tools/id/261/
Thank you in advance!
This is probably because you need to reindex Catalog URL Rewrites. Go to System->Index Management and reindex. (It's probably best to select all and reindex though just to be sure!)
After working through this, I ended up changing the .htaccess Mage::run() settings. I ended up having to change some of the base url setting in the core_data_config table to finish getting everything to work correctly. I also ended up having to set the SEO rewrites (System Config > General > Web > Search Engine Optimization > Use Web Server Rewrites) = No
I found that once index.php was included in the path then my site was working properly.
This is what i ended up doing and it removed the index file as well. Part of the issue is that I installed magento in /store/dir/
1) Login to admin section by using the URL
http://domain.com/index.php/admin
2) then go to “System >> Configuration >>Web >> Search Engines Optimization”
Use Web Server Rewrites : YES
3) Go to “System >> Configuration >>Web >>Secure”
Use secure URL Frontend: YES
** I used the second one **
4)Then create the .htaccess file under your the magento installed folder.
If the magento installed under document root ( /home/username/public_html) then add follogig rules into .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
and If the magento installed under /shop or directory then add the following rules into ” /home/username/public_html/shop/.htaccess ” file.
<IfModule mod_rewrite.c >
RewriteEngine On
RewriteBase /shop/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /shop/index.php [L]
</IfModule >
http://www.bestdesigns.co.in/blog/remove-index-php-url-magento
I am trying to get my Flask application working on Hostgator shared account. I am having troubles with getting a right configuration of mod_rewrite rules. My dispatch.fcgi appears as a part of URL e.g. www.example.com/dispatch.fcgi/news/. How can I fix it?
Here is my .htacess:
RewriteEngine On
AddHandler fcgid-script .fcgi
RewriteRule ^(dispatch\.fcgi/.*)$ - [L]
RewriteRule ^(.*)$ dispatch.fcgi/$1 [L]
I tried many variants none of them works for me.
Found a solution. Now it is in the Flask documentation. Check the "Configuring Apache" section.
I upgrade my magento store 1.4.1.1 to 1.6.1.0 following instruction from this link. Upgrade was successfully done. My Magento backend is working fine. But while I checking front end I got 404 error.
I tried various advice in Google. But none of them helps me.
If you have previous experience in this please share.
Edit :-
I think this problem is occurred due to multi store setup.so i share two table structures
core_store
core_store_group
Core_website
I found the problem myself:-
In "core_store" table some of the stores was disabled.While activate the all stores the problem is solved.
Clean the cache, rebuild catalog url rewrite index, check .htaceess and mod_rewrite
I had this same problem recently.
Check to see if any modifications of the root index.php file have been overridden by the upgrade.
You probably updated the $mageRunCode depending on what url you come to the site on, this will have been replaced by a default index.php file with the upgrade.
i have similar problem and i tried all solution above and also from google but its not solve the problem in the end i tried one solution that is in .htaccess file in root directory
############################################
## rewrite everything else to index.php
RewriteRule .* index.php [L]
</IfModule>
#########
i just comment the above line like
#RewriteRule .* index.php [L]
and then add this code
####
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /magento/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
this will fix my problem and then all categories page and products page are opening perfect and no more 404 error or forbidden error comes. just posted it might be its help others