Rewrite URL on Glassfish with Quercus' PHP - url-rewriting

I have Glassfish 3 server and have added Quercus 4.0.7 to to be able to run PHP applications on it. Everything works perfectly with it. Now I'm trying to run Question2Answer application on my server. I was able to open application but it's not allowing me to navigate from page to page because they are using .htaccess file to rewrite the URL. I was wondering how do we rewrite the URL in this case?
Here is what Question2Answer's .htaccess has inside:
DirectoryIndex index.php
RewriteEngine On
#RewriteBase /your-sub-directory
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L]
Do you have any solutions for that?

Use Tuckey's UrlRewriteFilter (which is inspired by mod_rewrite and offers similar functionalities) to implement the rewrite rules. Basically, you'll have to:
Get Quercus's war and unpack it
Download the filter and unpack it inside Quercus (this will put the filter jar inside WEB-INF/lib and the urlrewrite.xml under WEB-INF).
Declare the filter in the web.xml (see the install instructions).
"Port" your rewrite rules to the urlrewrite.xml file.
Repackage and deploy the war (or deploy it as an exploded archive).
The post Drupal on Glassfish with clean urls using Url Rewrite Filter discusses this approach. Adapt it to your needs.

Related

Laravel website 'uploaded on shared hosting' is showing directory structure instead of my specified web routes

I've uploaded the project on a shared hosting and it is showing the complete directory structure of the project.
I've searched for the solutions and changed my .htaccess file. This is my .htaccess file now:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
but it is still showing the same directory structure. Any help would be highly appreciated.
Laravel is not designed to be run on shared hosting. You'll have to manually change its structure to run it on shared hosting.
Follow this article: https://medium.com/laravel-news/the-simple-guide-to-deploy-laravel-5-application-on-shared-hosting-1a8d0aee923e
Though I will recommend to buy a private server for laravel.

How to remove index.php file from codeigniter

I referred the CodeIgniter Site and also checked various sites for information on how to remove index.php file from Mac OS X 10.10. But still index.php is unavoidable. I need steps to remove index.php from CodeIgniter on Mac OS 10.10.
This is working:
localhost/jenny/Learn/index.php/about
This is not working:
localhost/jenny/Learn/about
As long as you are running apache the operating system should not make a difference in this case.
You need to create a .htaccess file within the your root web directory (this is the directory where the index.php file is located) and within the .htaccess file you will want to include the following:
RewriteEngine On
RewriteOptions inherit
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
This will allow you to utilize the second url you have posted as it will determine if the requested resource is located within the webroot and if not then redirect to the index.php file without it needing to be included in the url.
If you are not running a different web server then the rewrite rule will be different but the principle is the same. Send all requests to index.php if not resource does not live in web root.
open path:/application/config/config.php
find : $config['index_page']='index.php'
replace : $config['index_page']=''

Netbeans still showing root folder

I'm starting a new Codeigniter project inside of Netbeans 7.3.1 and have the following set up for my file structure.
I have in the project properties set up as the web root is pointed to public_html inside of the text box. I also have this for my htaccess file as well as I have removed index.php from the ci config file.
My problem is that when I go to localhost/MyProject it still shows the foot folder and I don't know why.
Is there anyone that sees a mistake I have made somewhere.
-root
-application
-system
-public_html
-assets
.htaccess
index.php
Options -Indexes
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
#When your application folder isn't in the system folder
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]
# 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
Out of the box Netbeans doesn't come with CodeIgniter support, but that can easily be solved by installing the appropriate plugin:
https://kenai.com/projects/nbphpci/pages/Home
Due to the specific structure of a CodeIgniter project telling Netbeans that a CodeIgniter project is just another php project won't work correctly.
The detailed procedure to install this plugin can be found on their Wiki or here. Usage is explained here.
I think that you will have to restart a new project and properly activate CodeIgniter support in the project setup wizard, and that should be it.

.htacces file and MAMP

I have installed MAMP on my laptop and moved my web project (developed using CodeIgniter) under MAMP's webroot.
I use an .htaccess file to hide my index.php file within my urls and everything is working fine...almost, everything.
I'm able to surf my site locally as in my remote server but some folders/files are not recognized. Looks like they are missing or the path is not matching the physical location on my laptop.
Basically I have configuration like below:
MAMP
htdocs
myFolderSite
.htaccess
site
myApplicationFolder
.htaccess
config
controllers
views
.....
...
myPublicFolder
css
images
.....
...
Surfing my site locally css and images are not visible. All the required files are present under the proper folders within myPublicFolder.
The .htaccess file I'm using in myFolderSite appears as below
RewriteEngine On
RewriteBase /myFolderSite/
RewriteCond $1 !^(index\.php|images|upload|users|thumb|fckeditor|public|css|js|robots\.txt|sitemap2\.xml)
RewriteRule . index.php [L]
Am I missing something?
Thanks in advance
The CodeIgniter wiki has a good article on Mod Rewrite that is worth looking at. Specifically, these two lines will stop actual files and directories being redirected.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
I've used this across a few different servers and Macs, without too many problems, so hopefully it helps.

Apache mod_rewrite does not work

Im using a J2ee application with spring framework 2.0 on a apache tomcat 5.5. I have used URL mapping to change the extension from .jsp to .htm. I have an URL which looks like this
http://www.800promotion.com/promotion.htm?cid=1344159422528120632840257756098788
I want to change it to
http://www.800promotion.com/1344159422528120632840257756098788
I have referred samples of working on mod_rewrite. However I cant seem to get it working. These are the lines in my .htaccess file.
RewriteEngine on
RewriteRule ^([^/.]+)/?$ /promotion.htm?cid=$1 [L]
I have checked with my host and they said mod_rewrite was supported on the server. I do not have access to the httpd.conf file. However I have verified from the support that AllowOverride is set to all. When I hit the URL the page works fine however the URL doesnt get mapped. Where am I going wrong?
RewriteEngine On
RewriteRule ^(.+)$ promotion.htm?cid=$1 [QSA,L]
Try this
You need a correct .htaccess directives. Try the following solution:
RewriteEngine on
RewriteBase /
RewriteRule (.*) promotion.htm?cid=$1 [L,I,U]

Resources