473,405 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Re-write index.php to /home/ using htaccess

134 100+
Hi

i m using htaccess to rewrite my urls.,

In this instead of http://www.mysite.com/index.php i want the url as http://www.mysite.com/home/

any ideas??

and also i m using the following code to redirect to the http://www.mysite.com/index.php when a non-existing filename is typed..

Expand|Select|Wrap|Line Numbers
  1. .........
  2. .............
  3. RewriteCond %{REQUEST_FILENAME} !-f 
  4. RewriteCond %{REQUEST_URI} !^/Admin 
  5. RewriteRule ^ http://www.mysite.com/index.php
  6.  
  7.  
so i want the url to be displayed as http://www.mysite.com/home/ whenever http://www.mysite.com/index.php is called..And at the same time when an non-existing filename i,e url is passed it must be redirected to http://www.mysite.com/home/ instead of http://www.mysite.com/index.php


regards
vijay
Sep 13 '08 #1
6 8886
Atli
5,058 Expert 4TB
Hi.

You should simply look for "index.php" and redirect it to "/home/".
Using the [R] option will cause a redirect, which will cause the URL to change in the user's browser.

That should be as simple as:
Expand|Select|Wrap|Line Numbers
  1. RewriteRule ^index\.php$ /home/ [R]
  2.  
Sep 13 '08 #2
vjayis
134 100+
Hi.

You should simply look for "index.php" and redirect it to "/home/".
Using the [R] option will cause a redirect, which will cause the URL to change in the user's browser.

That should be as simple as:
Expand|Select|Wrap|Line Numbers
  1. RewriteRule ^index\.php$ /home/ [R]
  2.  


Hi

tried by placing it but page results by displaying the error message as

""
This webpage has a redirect loop.

The webpage at http://www.mysite.com/home/ has resulted in too many redirects
""

i think it may be due to the rewirte rule i hav placed for the non existing file or urls
Sep 13 '08 #3
Atli
5,058 Expert 4TB
Yea, that last rule in your code doesn't look quite right.
If I put that into the .htaccess file on a project I'm working on now I also get the "to many redirects" error.

Try removing that, see what happens.
Sep 13 '08 #4
vjayis
134 100+
tried and it also results in an error which says that

"
Oops! This link appears broken.
HTTP 404 - File not found.

"
Sep 13 '08 #5
Atli
5,058 Expert 4TB
Ok.

That may cause a problem, because re-directing back and forth like that ends up causing an indefinite loop.

There is a far easier solution, if you want.

Because index.php is an index file, if you simply specify the directory that contains the file, it will be executed.
In your case, that is the root directory.

So rather than showing example.com/home/ it would just show example.com/.
Expand|Select|Wrap|Line Numbers
  1. RewriteRule ^index\.php$ / [R]
  2.  
That way, you don't need to redirect the /home/ directory back to the index file and enter a loop. The index file would be automatically executed.

And if you want all non-existing files to go there as well, you could catch the 404 error and show the the index file, which would be re-directed like a normal link:
Expand|Select|Wrap|Line Numbers
  1. ErrorDocument 404 /index.php
  2.  
Sep 13 '08 #6
vjayis
134 100+
Hi

thanks for ur help., and it works good.,

but the rewrite rules written for index.php gets changed., and no probs i can get rid of it..

but i need it to be displayed as http://www.mysite.com/home/ instead of http://www.mysite.com/

anyother way ???
Sep 13 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Nel | last post by:
I have a question related to the "security" issues posed by Globals ON. It is good programming technique IMO to initialise variables, even if it's just $foo = 0; $bar = ""; Surely it would...
4
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as...
1
by: Chris | last post by:
Sorry to post so much code all at once but I'm banging my head against the wall trying to get this to work! Does anyone have any idea where I'm going wrong? Thanks in advance and sorry again...
11
by: James | last post by:
My form and results are on one page. If I use : if ($Company) { $query = "Select Company, Contact From tblworking Where ID = $Company Order By Company ASC"; }
4
by: Alan Walkington | last post by:
Folks: How can I get an /exec'ed/ process to run in the background on an XP box? I have a monitor-like process which I am starting as 'exec("something.exe");' and, of course the exec function...
1
by: John Ryan | last post by:
What PHP code would I use to check if submitted sites to my directory actually exist?? I want to use something that can return the server code to me, ie HTTP 300 OK, or whatever. Can I do this with...
8
by: Beowulf | last post by:
Hi Guru's, I have a query regarding using PHP to maintain a user profiles list. I want to be able to have a form where users can fill in their profile info (Name, hobbies etc) and attach an...
1
by: joost | last post by:
Hello, I'm kind of new to mySQL but more used to Sybase/PHP What is illegal about this query or can i not use combined query's in mySQL? DELETE FROM manufacturers WHERE manufacturers_id ...
2
by: JW | last post by:
I wanted have this as part of a flood control script: <? echo ("Flood control in place - please wait " . $floodinterval . " seconds between postings."); sleep(5); // go back two pages echo...
2
by: Frans Schmidt | last post by:
I want to make a new database with several tables, so I did the following: <?php CREATE DATABASE bedrijf; CREATE TABLE werknemers (voornaam varchar(15), achternaam varchar(20), leeftijd...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.