2

I have XAMPP installed, I run everything on my localhost/ So imagine I have localhost/website/index.php or www.website.com/index.php;

How can I delete index.php and/or replace it with something like; localhost/website/:) or www.website.com/:)

or show it like; localhost/website or www.website.com

Example;

$URLcapture = $_SERVER['PHP_SELF'];
$URLcustom = ":)";

$_SERVER['PHP_SELF'] = $URLcustom;
echo $_SERVER['PHP_SELF'];

This shows :) of course but how can I get :) in my URL?

Thank you, F4LLCON

EDIT

Under loaded modules I can see mod_rewrite.

STEPS BEFORE EVERYTHING -- START - In httpd.conf I've deleted;

# from infront of LoadModule rewrite_module modules/mod_rewrite. 

Changed;

<Directory />
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Deny from all
</Directory> 

and

<Directory "C:/xampp/cgi-bin">
    AllowOverride All
    Options +FollowSymLinks
    Order allow,deny
    Allow from all
</Directory>

STEPS BEFORE EVERYTHING -- END -

In .htaccess I've added

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L]

and also tried

RewriteEngine On
RewriteBase /
RewriteRule index.php nieuw.php

What am I doing wrong?

EDIT 2

Not touching .htaccess at all worked. 1. Closed xampp and apache.

  1. Edited httpd.conf in C:\xampp\apache\conf;

2a Start with above steps;

2a STEPS BEFORE EVERYTHING -- START - till

2a STEPS BEFORE EVERYTHING -- END -

2b. added at the end of http.conf;

<IfModule mod_rewrite.c>  
RewriteEngine on  
RewriteRule ^/home$ /spiderweb/Web-projects/Web-stage/Nieuwidw/index.php 
RewriteRule ^/link$ /spiderweb/Web-projects/Web-stage/Nieuwidw/link.php 
RewriteRule ^/contact$ /spiderweb/Web-projects/Web-stage/Nieuwidw/contact.html
RewriteRule ^/about$ /spiderweb/Web-projects/Web-stage/Nieuwidw/about.html
</IfModule>
  1. start xampp/apache and type localhost/home

3a. the website will open but the layout is not there. So it does not load style.css

3b. .css is in;

3b. C:\xampp\htdocs\spiderweb\Web-projects\Web-stage\Nieuwidw\includes

3c. images are in;

3c. C:\xampp\htdocs\spiderweb\Web-projects\Web-stage\Nieuwidw\includes\images

Next

  1. on home you can see "more" button under every product, if you press on more you will be redirected to the products page in link.php but every product gets it's own ID in the URL;

4a. http://localhost/link.php?id=126 so the page shows up; not found because the URL is different

How to fix these problems?

6
  • 1
    When you restarted your http server (which one are you using ?) what was added to the logs when the mod_rewrite was loaded ? any errors ? Commented Nov 29, 2011 at 12:37
  • One not, when I search for .htaccess in C:\xampp it finds 19 .htaccess files. I've just edited the one in C:\xampp\htdocs\xampp. Is that the correct one? Where can I find the logs? No errors shown on the page just loads with the same link.php in the URL Commented Nov 29, 2011 at 12:48
  • @ManseUK Do I need to edit .htaccess in my xampp (localhost) folder or create .htaccess file in my website folder? Commented Nov 29, 2011 at 13:07
  • 1
    What ever you have set as your document root - so where ever the index.php file is Commented Nov 29, 2011 at 13:13
  • @ManseUK I've edited my post again, under EDIT 2 could you give it a look? I've up-voted your comments :) Commented Nov 29, 2011 at 13:56

2 Answers 2

2

In php :

header("Location: http://www.example.com/");

But the best way is using htaccess (like ManseUK says)

Sign up to request clarification or add additional context in comments.

1 Comment

If I add header("Location: localhost/spiderweb/Web-projects/Web-stage/Nieuwidw/"); in my php file, and try to load it in my browser, the browser gives me page not found. It will redirect to localhost/spiderweb/Web-projects/Web-stage/Nieuwidw of course
1

If you are able to the best way of doing this is using mod_rewrite - you then include a rule like the one below and the index.php is hidden

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

2 Comments

Thank you, I've tried some tutorials about that but it does not change anything. Is there any other way?
@F4LLCON when you run phpinfo() on your server do you have the mod_rewrite module enabled ? what do you see in the logs ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.