my first page in my website called index.html
when I put in the address bar :
http://websit/index.html it works
but
now my boss asked me that he wants the name just http://websit/index
how can I do that?
Standard web server behavior is to just load the "index.html" file as the root file of a path call. Meaning this:
http://websit/
Is the same as this:
http://websit/index.html
Doing something like this (below) will only cause more problems since it would seem that index is a path instead of a file:
http://websit/index
So any if you want to clean things up just make any reference to http://websit/index.html just http://websit/
If you are using Apache, then, you need to check if Mod Rewrite is enabled, and then, read articles about .htaccess and mod rewrite.
The solution:
Create a file with this name exactly .htaccess on root directory (where the index.html) is there. Then, copy this code (paste it inside the .htaccess file) and test it again using website/index without .html
#comments
RewriteEngine On
#base directory for this file, if its root, then its one /, if its test then its /test
RewriteBase /
#if the URL for the resource that requested is not exist as file
RewriteCond %{SCRIPT_FILENAME} !-f
#if the URL for the resource not exist as directory
RewriteCond %{SCRIPT_FILENAME} !-d
#then it anything types after the website/() redirect it to ().html
RewriteRule ^(.*)$ $1.html [NC,L]
#the ^ and $ used for matching whole string (from beginning to end)
#the () used for grouping matching strings
#the . used for matching any character
#the $1 represents the match group, for our example we used one () then its $1
[1] http://httpd.apache.org/docs/current/howto/htaccess.html
Related
I am running an Apache 2.4 webserver.
I have a file: http://192.168.0.12/test/index.html
Right now, if I access this file, it displays this in the address bar:
http://192.168.0.12/test/
All I want, is for it to instead display this:
http://192.168.0.12/test
Edit: I decided to get around the problem by instead storing everything I needed from the /test/ directory in the /test-content/ directory, and changing the /test/index.html file to just /test.html
Edit the .htaccess file and add the below rule:
RewriteEngine On
RewriteRule ^test$ /test1/ [L]
I am attempting to move to nginx...
I have an app running in apache using the following mod_rewrite commands:
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/([a-z\-0-9]+)/(.*)$ /$1/index.php/$2 [E=USERKEY:$1,L]
The PHP backed we are using processes items in the form of:
/[USERKEY]/index.php/[module]/[action]/[etc...]
We want to pass every hit (where there is not a static file on disk) to the index.php file for processing in a format where:
http://www.myapp.com/bobsmith/rockstar/add?q=45678
would translate into:
/var/www/some_static_path/bobsmith/index.php/rockstar/add?q=45678
I know some CMS products do something similar and I located a lot of examples but we have this odd USERKEY payload (which is part of index.php's path) causing issues for my configuration. Additionally, I struggled dealing with the slash (/) after the index.php. The error logs would show:
"/bobmsith/index.php/login" failed (20: Not a directory)
When attempting to browse to: http://www.myapp.com/bobsmith/login
I have tried working with rewrite, if(s), different types of location regex, try_files, fastcgi_split_path_info... I cannot find the cocktail for success!
any/all help appreciated; thanks all!
I have this site which uses multisite manager for minisites.
The issue i am having is that my minisites are in subfolder of the main site and when i use
{path='minisite/group'}
it creates a path like this
/index.php/minisite/group
when in fact i need the following
/minisite/index.php/group
is there a to make it aware of the baseurl for the minisite being in a subfolder.
One way to get around this would be to remove "index.php" from your URLs. This is a common task in ExpressionEngine development. There's a great how-to on removing "index.php" from your ExpressionEngine sites here. I've also used the following code in my .htaccess file to remove the "index.php":
# If you can't access the control panel at the folder level (ie "http://site.com/system/"), uncomment the following line.
# DirectoryIndex index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?/$1
After removing "index.php" from your URLs, you should be able to use {path="} without error. Let us know if this isn't the case.
I want to clear my url with codeigniter, I have these types of urls:
www.ggg.com/index.php/page/8/name.html
and I want to trasform these like
www.ggg.com/index.php/name.html or www.ggg.com/name.html
Is this possible modifying the file route.php?
Actually to get rid of the index.php you need to edit out the index.php file from config.php (in your config folder inside application).
.htaccess for clean urls:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
and to get rid of the .html just eliminate that 'suffix' again in the config/config.php file.
That should be all you need, the .html ending is just for show
As far as turning something like page/8/name into name, I would think twice about how that would work, your page or 8 most likely mean something, so your name would have to have code making it unique. My guess is that page = 8 is the value, and the name is just for the friendly url look.
Edit the routes.php file and add the line:
$route['name'] = "page/8/name";
This is all explained in the docs: http://codeigniter.com/user_guide/general/routing.html
To remove the index.php you will need a .htaccess file. There is an example in the ci docs or google it and you will find loads of tutorials. I'm sure there are even some examples here.
I am having this in a .htaccess:
RewriteEngine On
RewriteRule ^videos/([0-9]+)/?$ vis_film.php?id=$1 [NC,L]
My page is
root/directory/directory/videos/vis_film.php?id=2
but i want it to be
root/directory/directory/videos/2/
And ive placed the .htaccess file inside videos/, is that right? and what have i done wrong?
If you’re already in videos/, you need to remove that path prefix from your pattern:
RewriteRule ^([0-9]+)/?$ vis_film.php?id=$1 [NC,L]
You need to put it in the 2nd directory (root/directory/directory/videos/)