Jump to content

.htaccess file -- not showing proper URL / how to redirect from index


justin7410

Recommended Posts

Hey guys,

 

i have a .htaccess file that i am trying to modify.

 

apparently i modified this before to remove extensions from being necessary ( i.e .php) 

 

then i made a modification to remove the www from the URL so that it would be strictly http://websitenamehere.com

 

this did not work and i tried to remove the code from the .htaccess file, as you will see there is no code now for this. Yet, when go to the site it works and shows its SERP as websitename.com.  this is extremely frustrating and looks very amateurish.

 

.HTACCESS FILE

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /profile.php?username=$1


# ---- Establish a custom 404
ErrorDocument 404 /filenotfound.php


# ---- Prevent directory file listing index
IndexIgnore *


# ---- Make Pages render with no ext
Options +Multiviews


AuthName "websitename.com"
AuthUserFile "/home/websitename/.htpasswds/public_html/passwd"

also on a side issue if anyone has any input, how can i remove the .index extension from showing, i want to to a redirect from the .htaccess file, where instead of index.php it would just show the domain.name.

 

Thank a bunch guys, any suggestions or help would be great.

Edited by justin7410
Link to comment
Share on other sites

# ---- Prevent directory file listing index
IndexIgnore *
Options -Indexes is better.

 

also on a side issue if anyone has any input, how can i remove the .index extension from showing

.php extension? Enabling MultiViews should let you do that already. Try it.

 

i want to to a redirect from the .htaccess file, where instead of index.php it would just show the domain.name.

Then don't put /index.php in the link.
Link to comment
Share on other sites

# ---- Prevent directory file listing index
IndexIgnore *
Options -Indexes is better.

 

.php extension? Enabling MultiViews should let you do that already. Try it.

 

Then don't put /index.php in the link.

 

 

Hey, Thanks for the reply !

 

your post was very helpful but not quite as helpful as i needed.

 

 

i dont think i stated my issue clearly.

 

i want index.php to be the file that is being directed to, but while index is being directed to , using .htaccess you can redirect the index file to your main page without showing the file name.

 

using MultiViews only removes the extension of .php not the file name. I thought using IndexIgnore * or -Indexes would accomplish what i was trying to do with that issue. Yet, nothing happens for either, im still directed to the index file with index showing.

 

My main issue of www. not showing up in my URL is what i really want an answer to or solution if anyone can help. just look at the OP and you will get a better idea of the issue at hand.

 

thanks

Link to comment
Share on other sites

i want index.php to be the file that is being directed to, but while index is being directed to , using .htaccess you can redirect the index file to your main page without showing the file name.

And as long as index.php is a DirectoryIndex and as long as you don't actually link to "/index.php" then it will work without changes.

 

using MultiViews only removes the extension of .php not the file name. I thought using IndexIgnore * or -Indexes would accomplish what i was trying to do with that issue. Yet, nothing happens for either, im still directed to the index file with index showing.

I guess I was confused and thought that when you said to remove the extension that you wanted to remove the extension. I should have known you meant the entire file name.

 

My main issue of www. not showing up in my URL is what i really want an answer to or solution if anyone can help. just look at the OP and you will get a better idea of the issue at hand.

It's not going to do that after you remove any code that tries to remove the "www" subdomain. So... put the code back in. If you have problems making it work then we need to see what you have, not what you don't have.
Link to comment
Share on other sites

And as long as index.php is a DirectoryIndex and as long as you don't actually link to "/index.php" then it will work without changes.

 

I guess I was confused and thought that when you said to remove the extension that you wanted to remove the extension. I should have known you meant the entire file name.

 

It's not going to do that after you remove any code that tries to remove the "www" subdomain. So... put the code back in. If you have problems making it work then we need to see what you have, not what you don't have.

 

Yes i would love to show you the sourced code for the issue.

 

one of the head scratching things about this issue is, this file you see in the OP is the live website .htaccess file. So for showing you what i have and dont have, that is basically the "whole enchilada" sort of speak. 

 

If you have any suggestions as to why there is hidden code in the .htaccess file ? i have tried to edit it through both cpanel ( legacy file manager) & notepad++ , both show the OP code.

 

thanks again man

Link to comment
Share on other sites

 

 

 

And as long as index.php is a DirectoryIndex and as long as you don't actually link to "/index.php" then it will work without changes.

 

 

 

i am sorry , i am a somewhat noob when it comes to PHP , can you elaborate a bit what you mean by a DirectoryIndex ? 

 

i also link to my index.php ( for ex : if i have a website logo and a user clicks on the logo, it should take the user back to the index.php, which is your homepage.)

 

my index.php is located in my www directory 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.