Current location: Hot Scripts Forums » Other Discussions » Web Servers » Redirect script for php htaccess


Redirect script for php htaccess

Reply
  #1 (permalink)  
Old 10-28-08, 03:56 PM
leavi24 leavi24 is offline
Newbie Coder
 
Join Date: Oct 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Redirect script for php htaccess

I have an assignment with the lion framework.. being new to this i have a problem, please help me out with a solution.. woud be of great help:

Can we alter the .htaccess file in the lionDemo directory so that

http://localhost/LionDemo/index.action

and

http://localhost/LionDemo/ produce the same result.

How do we do that?

please advise
Reply With Quote
  #2 (permalink)  
Old 10-28-08, 09:04 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,515
Thanks: 20
Thanked 109 Times in 106 Posts
http://httpd.apache.org/docs/1.3/mod...directoryindex

.htaccess

DirectoryIndex index.action
Reply With Quote
  #3 (permalink)  
Old 10-29-08, 03:36 AM
leavi24 leavi24 is offline
Newbie Coder
 
Join Date: Oct 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Dear Wirehopper

Thanks for the reply but how do i get this to work? the script in the htaccess says this:
Code:
#Security options:
Options +FollowSymLinks
Options -Indexes

<Files ~ "\.(txt|ini|inc|xml)$">
Deny from all
</Files>

############ Rewrite Engine ##############
<IfModule mod_rewrite.c>
  RewriteEngine On
  #fix the following directive if you experience problems with url redirections:
  RewriteBase /LionDemo

  #Skip routing for existent requested files/directories:
  RewriteCond %{REQUEST_FILENAME} -f [OR] 
  RewriteCond %{REQUEST_FILENAME} -d  
  RewriteRule .* - [L]

  #Redirect the rest of requests to the index.php:
  RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
what is the best possible solution please suggest..

Greatful

Last edited by Nico; 10-29-08 at 12:28 PM. Reason: Wrappers.
Reply With Quote
  #4 (permalink)  
Old 10-29-08, 03:38 AM
leavi24 leavi24 is offline
Newbie Coder
 
Join Date: Oct 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
wirehopper please see

Quote:
Originally Posted by wirehopper View Post
http://httpd.apache.org/docs/1.3/mod...directoryindex

.htaccess

DirectoryIndex index.action
Thanks for the reply but how do i get this to work? the script in the htaccess says this:
Code:
#Security options:
Options +FollowSymLinks
Options -Indexes

<Files ~ "\.(txt|ini|inc|xml)$">
Deny from all
</Files>

############ Rewrite Engine ##############
<IfModule mod_rewrite.c>
  RewriteEngine On
  #fix the following directive if you experience problems with url redirections:
  RewriteBase /LionDemo

  #Skip routing for existent requested files/directories:
  RewriteCond %{REQUEST_FILENAME} -f [OR] 
  RewriteCond %{REQUEST_FILENAME} -d  
  RewriteRule .* - [L]

  #Redirect the rest of requests to the index.php:
  RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
i need to alter the .htaccess file in the lionDemo directory so that http://localhost/LionDemo/index.action and

http://localhost/LionDemo/ produce the same result.

tried ways to do it but cant get it to execute..
what is the best possible solution please suggest..

Greatful

Last edited by Nico; 10-29-08 at 12:28 PM. Reason: Wrappers.
Reply With Quote
  #5 (permalink)  
Old 10-29-08, 07:54 AM
aparraga aparraga is offline
Newbie Coder
 
Join Date: Oct 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Better than that, if you are using lion framework, my recommendation is to avoid change the .htaccess: Lion framework brings his own url routes engine, so you are able to define your own url alias, where to route request, ... within the config/routes.xml file (see http://lionframework.org/documentati...uting.pkg.html for more details about routes)

So, to produce the same result with http://localhost/LionDemo/ and with http://localhost/LionDemo/index.action, you can create a rule within the routes.xml like the following one:
Code:
            <route id="index" uri-pattern="^\/$">
              <front-controller class="__HttpFrontController"/>
              <action controller="index" code="default"/>
            </route>
(not sure if "^\/$" or "^\/LionDemo\/$". Well, in any case, the uri-pattern allows you to define a regular expression matching whatever route you need to handle)

So, with this rule, you are telling the lion framework that your route as '/' will be redirected to the index controller (default action), which is the same controller/action that you are executing by ussing the index.action within the url.

That's all.

Last edited by Nico; 10-29-08 at 12:28 PM. Reason: Wrappers.
Reply With Quote
  #6 (permalink)  
Old 10-29-08, 12:23 PM
leavi24 leavi24 is offline
Newbie Coder
 
Join Date: Oct 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by aparraga View Post
Better than that, if you are using lion framework, my recommendation is to avoid change the .htaccess: Lion framework brings his own url routes engine, so you are able to define your own url alias, where to route request, ... within the config/routes.xml file (see http://lionframework.org/documentati...uting.pkg.html for more details about routes)

So, to produce the same result with http://localhost/LionDemo/ and with http://localhost/LionDemo/index.action, you can create a rule within the routes.xml like the following one:

<route id="index" uri-pattern="^\/$">
<front-controller class="__HttpFrontController"/>
<action controller="index" code="default"/>
</route>

(not sure if "^\/$" or "^\/LionDemo\/$". Well, in any case, the uri-pattern allows you to define a regular expression matching whatever route you need to handle)

So, with this rule, you are telling the lion framework that your route as '/' will be redirected to the index controller (default action), which is the same controller/action that you are executing by ussing the index.action within the url.

That's all.
Thanks a lot sir,

Wold try that soon as i get my access to the lab in the next schedule.

Hope u wouldnt mind if i would ask you for some more of php as it progresses?
Reply With Quote
  #7 (permalink)  
Old 10-29-08, 12:26 PM
aparraga aparraga is offline
Newbie Coder
 
Join Date: Oct 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Sure! please
Reply With Quote
  #8 (permalink)  
Old 10-29-08, 10:32 PM
leavi24 leavi24 is offline
Newbie Coder
 
Join Date: Oct 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by aparraga View Post
Better than that, if you are using lion framework, my recommendation is to avoid change the .htaccess: Lion framework brings his own url routes engine, so you are able to define your own url alias, where to route request, ... within the config/routes.xml file (see http://lionframework.org/documentati...uting.pkg.html for more details about routes)

So, to produce the same result with http://localhost/LionDemo/ and with http://localhost/LionDemo/index.action, you can create a rule within the routes.xml like the following one:
Code:
            <route id="index" uri-pattern="^\/$">
              <front-controller class="__HttpFrontController"/>
              <action controller="index" code="default"/>
            </route>
(not sure if "^\/$" or "^\/LionDemo\/$". Well, in any case, the uri-pattern allows you to define a regular expression matching whatever route you need to handle)

So, with this rule, you are telling the lion framework that your route as '/' will be redirected to the index controller (default action), which is the same controller/action that you are executing by ussing the index.action within the url.

That's all.

Sir,

I tried both the ways ("^\/$" or "^\/LionDemo\/$") for running

http://localhost/LionDemo/

but the url returned as

mhtml:http://localhost/Liondemo/

saying internet explorer cannot display the webpage.

Please guide me through as i need to turn it in the earliest.
Reply With Quote
  #9 (permalink)  
Old 10-29-08, 10:34 PM
leavi24 leavi24 is offline
Newbie Coder
 
Join Date: Oct 2008
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy

Quote:
Originally Posted by wirehopper View Post
http://httpd.apache.org/docs/1.3/mod...directoryindex

.htaccess

DirectoryIndex index.action
Tried doing this too but it doesnt work..

is there anyother process... please let me know
Reply With Quote
  #10 (permalink)  
Old 10-30-08, 09:58 AM
aparraga aparraga is offline
Newbie Coder
 
Join Date: Oct 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Try with just "\/$" within your route.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Submit Redirect Script mduensing PHP 2 07-06-06 12:46 PM
Simple Redirect Script shawnm Script Requests 3 12-26-05 08:49 AM
Login and Redirect user script alistairgd Script Requests 4 01-03-05 03:30 PM
Pre-load Image Script then Redirect? thefoxbox PHP 3 11-25-04 02:29 PM
Is there any integrity of script rankings? webmaster@atmanager.com Hot Scripts Forum Questions, Suggestions and Feedback 17 08-06-04 12:12 AM


All times are GMT -5. The time now is 01:28 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.