0

i want to show only domain name in address bar. i am new in programming nd using core php. my .htaccess code is:

        <IfModule mod_rewrite.c>
        RewriteBase /
        Options +FollowSymlinks -MultiViews
        RewriteEngine on
        # to make `/path/index.php` to /path/
        RewriteCond %{THE_REQUEST} ^GET\s(.*/)index\.php [NC]
        RewriteRule . %1 [NE,R=301,L]
        RewriteCond %{THE_REQUEST} ^GET\s.+\.php [NC]
        RewriteRule ^(.+)\.php$ /$1 [NE,R=301,L,NC]
        RewriteCond %{REQUEST_URI} !\.php$ [NC]
        RewriteCond %{REQUEST_FILENAME}.php -f
        RewriteRule . %{REQUEST_URI}.php [L]
        </IfModule>

this is working fine but it shows the result like this http://mysite.com/about http://mysite.com profile_view?name=Apoorva%20Chauhan%20GMAIL%20&&%20user_type=User

i just want to hide complete url expect my domain name. url should be like this www.mysite.com/ no matter which link i clicked. and above code only hide index.php completely. My project deadline is already over i wasted 1 week on this topic. but i failed. Please help me. Thanks In Advance.

4

3 回答 3

2

i used javascript to hide or change the entire url. and it's working fine now. but i am not completely satisfy with it.

  <script type='text/javascript'>
  if(history.replaceState) history.replaceState({}, "", "/");
  </script>  

Note : where / is the path u want to show.

it shows the url like mysite.com no matter which link i have clicked. but i have a problem with this code while reloading the page the complete url with query string blinks into address bar.

于 2013-10-08T05:36:19.737 回答
2

Use document.location.replace('URL');

The browser will not build a history, and will just show the base http://URL/# no matter what page within the site.

于 2015-06-17T21:44:16.757 回答
-1

I think (not sure from the description) what you want is a single page website. If that's the case, you're approaching this all wrong. This is not achieved through .htaccess, but through js/ajax. You can find here an example of such a web application.

于 2013-10-07T13:12:04.033 回答