LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-19-2013, 05:45 AM   #1
mwkemo1
LQ Newbie
 
Registered: Jun 2013
Posts: 4

Rep: Reputation: Disabled
Apache won't display filename on address bar


Hello to all. I'm having problem with displaying index.php on address bar. If you go to http://www.example.com it will render what ever file is in DirectoryIndex directive, in most cases index.php or index.html, but it will NOT show index.php in address bar. I would like to show filename when some clicks on the link. Not sure how to achieve this. This is my current .htaacess file

Code:
DirectoryIndex	index.php

Options -Indexes

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* 404.html [L]
 
Old 06-19-2013, 11:39 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Hello to all. I'm having problem with displaying index.php on address bar. If you go to http://www.example.com it will render what ever file is in DirectoryIndex directive, in most cases index.php or index.html, but it will NOT show index.php in address bar. I would like to show filename when some clicks on the link. Not sure how to achieve this.
IMHO it's good not showing what the index file is. Anyway if you want to display it you can add the next 2 lines
Code:
RewriteCond %{REQUEST_URI} ^/$
RewriteRule .* /index.html [R=301,L]
Regards
 
Old 06-19-2013, 12:47 PM   #3
mwkemo1
LQ Newbie
 
Registered: Jun 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks for the replay. Almost there. When I refresh the page its just reloading over and over again. In the end my URL looks like this:
Code:
http://example.com/naslovnica.php?naslovnica.php%3fnaslovnica.php%253fnaslovnica.php%25253fnaslovnica.php%2525253fnaslovnica.php%252525253fnaslovnica.php
naslovnica.php is my index.php, translates as homepage.php, that's why I want to show it on address bar.
I'm not sure what's causing the page to refresh over and over again. Don't know if it maters, but my page is Ajax based.

Last edited by mwkemo1; 06-19-2013 at 12:49 PM.
 
Old 06-19-2013, 01:17 PM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
You may add a trailing "?" to stop appending the URI requested in the rewritten URL.
And maybe use another "is not a file" RewriteCond:
Code:
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} ^/$
RewriteRule .* /index.html? [R=301,L]
 
Old 06-19-2013, 04:51 PM   #5
mwkemo1
LQ Newbie
 
Registered: Jun 2013
Posts: 4

Original Poster
Rep: Reputation: Disabled
Still doesn't work. Something is wrong with my hosting server settings. I did try this rules on other server and it works. On my hosting server the page just reloads over and over again. I will mark this thread as solved. Thanks for help.
 
Old 06-20-2013, 02:43 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by mwkemo1 View Post
Still doesn't work. Something is wrong with my hosting server settings. I did try this rules on other server and it works. On my hosting server the page just reloads over and over again. I will mark this thread as solved. Thanks for help.
Hmm, check if Multiviews is enabled and disable it with
Code:
Options -Multiviews
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache won't start, says it can not bind to address thllgo Linux - Software 11 01-30-2012 04:40 PM
[SOLVED] Apache won't start (Gentoo): could not find IPv4 address SkyerSK Linux - Software 1 07-23-2011 01:59 AM
[SOLVED] changed apache port, now pages won't display klingoncowboy4 Linux - Server 2 05-16-2011 04:56 PM
Apache won't display files in DocumentRoot PiGuy Linux - Newbie 6 01-21-2005 01:33 PM
Apache SSL started, pages won't display Manuel-H Linux - General 1 04-16-2003 11:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration