Results 1 to 11 of 11

Thread: Shortening of url

  1. #1
    New user
    Join Date
    12-06-11.
    Posts
    13

    Default Shortening of url

    Hey there Contao community!

    Is there any way to shorten the very ugly url's in contao?

    i.e. http://my-domain-name/index instead of http://my-domain-name/index.php/index.html

    This is very important for me, beause of user-friendliness

  2. #2
    User
    Join Date
    01-20-11.
    Location
    Germany
    Posts
    77

    Default Re: Shortening of url

    Hi,

    sure there is. You have to rename .htaceess.default in the root directory to .htaccess (for the rewrite rules) and then Settings/Front end configuration/Rewrite URLs

    Jan
    Free support only here in the forum.
    Please report bugs for my extensions using http://www.contao-forge.org. Thanks!
    Requests for Contao support and development please send mail to jan@theofel.de

  3. #3
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: Shortening of url

    You can also get rid of the .html suffix. It is also a setting made at the settings page and a change in the .htaccess file. Instructions on how to change the htaccess file are in the bottom of the file itself.

  4. #4
    New user
    Join Date
    12-06-11.
    Posts
    13

    Default Re: Shortening of url

    Ok, thank you - I'll try that

  5. #5
    New user
    Join Date
    12-06-11.
    Posts
    13

    Default Re: Shortening of url

    Hi again!

    I have tried to do what you said and have altered the settings in the backend, but I can't seem to figure out how to get the mod_rewrite to work :?

    I have done as you said jan.theofel, but it does not work. Should I alter something in the .htaccess file?

  6. #6
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: Shortening of url

    There is one thing you need to check... Mod_rewrite is an Apache module which is not available for IIS. If you are on IIS there is another method, but it takes some more effort.

    This is something I copied from my own post here:

    To get URL rewrite working you could look at: viewtopic.php?f=4&t=2504

    Quote Originally Posted by Ruud
    I happen to have solved this problem with TYPOlight on an IIS server. First off; IIS does no rewriting of its own. Or at least not that I know of, so just changing the .htaccess and the rewrite switch will not help you much!

    You need to install an isapi module for that. I used Ionic's Isapi Rewrite Filter. When you have that filter installed (follow their instructions) then you need to construct a version of the .htaccess file that the rewriter will understand (it will not use the existing .htaccess files)

    The file I made is called IsapiRewrite4.ini:
    Code:
    # IsapiRewrite4.ini
    #
    # TYPOlight Rewrite URL
    #
     
    #RewriteLogLevel 5
    RewriteRule ^(/?index\.php.*)$ $1 [L]
    RewriteRule ^(/?preview\.php.*)$ $1 [L]
    RewriteRule ^(/?)(.*\.html)$ $1index.php/$2 [L]
    
    #RewriteRule (.*css)$ $1 [I,L]
    #RewriteRule (.*xml)$ $1 [I,L]
    #RewriteRule (.*js)$ $1 [I,L]
    #RewriteRule ^/(?!index.php)(?!tl_files)(?!system)(?!plugins)(?!templates)(?!typolight)(?!contao)(.*)$ /index.php/$1 [I,L]
    There are no guarantees that my file will work, but at least it gives you an almost complete method as to how to get this working!

    ps, also I am not sure what IIS server I did this on. That means that this method might only work for some IIS versions. Additionally; it was for an earlier TYPOlight version so the htaccess for contao may have changed. I did include contao into the rules I posted above.
    This was written for an older Contao version. The rewrite rules might need some adjusting.

  7. #7
    New user
    Join Date
    12-06-11.
    Posts
    13

    Default Re: Shortening of url

    Thank you, but I am currently running apache 2.2.8 so that is unfortunately not the problem :/

    EDIT: FYI I'm getting a 404 error - not "page not found"

  8. #8
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: Shortening of url

    Can you test if mod_rewrite itself is installed correctly.

  9. #9
    New user
    Join Date
    12-06-11.
    Posts
    13

    Default Re: Shortening of url

    It seems that it is, because I can easily remove the ".html" extension withour any trouble. But when I remove the "index.php" it gives me this error :/ (Sorry I didn't mention this in the earlier post)

  10. #10
    User
    Join Date
    01-20-11.
    Location
    Germany
    Posts
    77

    Default Re: Shortening of url

    Hello,

    Quote Originally Posted by KristianK
    It seems that it is, because I can easily remove the ".html" extension withour any trouble. But when I remove the "index.php" it gives me this error :/ (Sorry I didn't mention this in the earlier post)
    Getting rid of ".html" is a Contao thing, not a rewrite thing. As your hoster if mod_rewrite is active and if you can use it inside your .htaccess file.

    Jan
    Free support only here in the forum.
    Please report bugs for my extensions using http://www.contao-forge.org. Thanks!
    Requests for Contao support and development please send mail to jan@theofel.de

  11. #11
    New user
    Join Date
    12-06-11.
    Posts
    13

    Default Re: Shortening of url

    That seemed to be the problem Thank you!

    To anyone else having this "problem" here is what I did:

    • Edit the settings to rewrite urls (under settings -> Front end konfiguration)[/*:2vt1q16u]
    • Edit the .htaccess.default to .htaccess[/*:2vt1q16u]
    • Make sure .htaccess is enabled on your server (which is NOT the case on AppServ!)[/*:2vt1q16u]

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •