Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Removing index.php?p=/ from url?

edited July 2010 in Vanilla 2.0 - 2.8
How would I remove index.php?p=/ from the url of my forums?

Comments

  • edit your .htaccess add


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

    hope can help you ^^
  • fuwanekofuwaneko New
    edited July 2010
    @hginli It won't remove "index.php?p=/" part from the urls, but will allow not to use it, i.e. "http://myforum.com/discussions" will work beside "http://myforum.com/index.php?p=discussions". And you have wrong slash direction at the last line. It should be "index.php/?p=$1". Also if forum reside in subdirectory "forumsubdir", you need to add "RewriteBase /forumsubdir/" after "RewriteEngine On". And this method will work only with Apache. For Nginx and Lighttpd you'll have to do something else.

    EDIT: Vanilla 2 actually has an option to enable friendly URLs, after digging through config file I was able to find it.
    Edit conf/config.php and add $Configuration['Garden']['RewriteUrls'] = TRUE; and it'll work.
  • hginlihginli New
    edited July 2010
    but i is from V2 version .htaccess copy @_@

    / and \ can use?
  • ToddTodd Chief Product Officer Vanilla Staff
    @sammyman, You need to make sure your server configuration supports url rewriting properly which means that your .htaccess file has to be configured to your specific server. If you are on nginx there are other posts on this forum to help you out.

    If you don't have friendly urls after an install then most-likely you need to configure something. The install routine does a check to see if it can support friendly urls.

    Once everything is configured correctly you can make sure by removing index.php?p= in your browser manually and making sure the correct pages are displayed. don't just do this on /discussions.

    Once everything is working so what @fuwaneko did and edit conf/config.php and add
    $Configuration['Garden']['RewriteUrls'] = TRUE;
  • I edited the htaccess file, and changed the config to true and it worked. Thanks.
  • LincLinc Detroit Admin
    @fuwaneko @Todd I had the same issue on a recent install; Rewrite was disabled by default for some reason. Caused a moment of confusion for sure.
  • ToddTodd Chief Product Officer Vanilla Staff
    The long and the short of it is that friendly urls is the most difficult feature to get to work across the wide range of servers our there. We do a simple check to see if they are supported on install, and if that check fails we turn them off.

    It's possible that the check fails, but friendly urls are still supported. It's also possible that a simple change to the htaccess file also works.

    The thing is, if we disable friendly urls, but the server supports them then the site still works. If we enable friendly urls, but the server doesn't support them then the site is pooched (that's a technical term by-the-way).

    There may be things we can do to make the tests better, but I think most of our work is going to have to be done with documentation.
  • ToddTodd Chief Product Officer Vanilla Staff
    @sammyman, what did you do to your htaccess file to get it to work?
  • @Todd I did as @hginli said above and as you said above as well.
  • neyawnneyawn New
    edited July 2012

    Okay, here is the thing. I have recently moved hosting. I am told URL rewrite option in ON by default.

    On my previous hosting, I had managed to remove index.php?p= from all URLs on my forum. I had done so by simply:-

    1. editing the config.php file and setting the $Configuration['Garden']['RewriteUrls'] = TRUE;
    2. Making required changes in .htaccess

    All my links were prettyURLs

    Now in my new installation, I am told URL rewrite option in ON by default.

    1. My forum is currently installed in a folder called /upsc
    2. My .htaccess file looks like this :-

    RewriteEngine on RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$ RewriteCond %{REQUEST_URI} !^/upsc/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /upsc/$1 RewriteCond %{HTTP_HOST} ^(www.)?mydomain.com$ RewriteRule ^(/)?$ upsc/index.php?p=/ [L]

    1. I haven't enabled RewriteURL in config.php (if I do, it gives me a 404 error)

    2. When I type mydomain.com/upsc/discussions It throws up a 404 error. It only works when I type mydomain.com/upsc/index.php?=/discussions.

    Because of this, all the previous prettyURL links to my website and even google search results are broken.

    What am i missing? :-(

    @Lincoln @422 Can you point me in the right direction?

  • I want my website's default URL to be mydomain.com/upsc as it was that way on my previous hosting.

  • ToddTodd Chief Product Officer Vanilla Staff

    If you are installed in the upsc folder then try just using the default .htaccess that comes with Vanilla.

  • Thanks for the reply!

    That does help a bit. Could you tell me what I would need to do if I wanted my URL to be mydomain.com/upsc instead of mydomain.com

    And mydomain.com/upsc/discussions is desired instead of mydomain.com/discussions ?

    Any change in .htaccess?
    Because thats how my URL is linked from other places. changing mydomain.com/upsc to mydomain.com would break those links.

    A quick reply would be helpful

  • Thanks @Todd

    I have moved my installation to / instead of /upsc. That fixes all my woes except broken links from other websites. Guess Google will index me with the new set up and update the search result links.

    At least I have prettyURLs now.

  • I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • the answer was given 8 years ago and was already part of the core. If you read the discussion you commented on you wouldn't be asking.

    grep is your friend.

Sign In or Register to comment.