Jump to:

23368 Posts in 18143 Topics by 2863 members

General Questions

SilverStripe Forums » General Questions » .htaccess - rewrite

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 2756 Views
  • banal
    Avatar
    Community Member
    901 Posts

    Re: .htaccess - rewrite Link to this post

    @Stijn: Do you get a 404 when trying to access the products.asp URLs? Or what is the issue? Maybe you have to set the RewriteBase as well, or change the RewriteRule.. it all depends on your Site structure. Is the site running in a subfolder by any chance?

  • Stijn
    Avatar
    Community Member
    46 Posts

    Re: .htaccess - rewrite Link to this post

    | Do you get a 404 when trying to access the products.asp URLs? Or what is the issue?

    Yes, when I look for a url like this: /products.asp?productgroupid=5&language=nl I get the 404 error that I set in SilverStripe.

    I don't want the error when people use that url.

    | Is the site running in a subfolder by any chance?

    No subdir ..

  • banal
    Avatar
    Community Member
    901 Posts

    Re: .htaccess - rewrite Link to this post

    Post the contents of your .htaccess and the link to your site?

  • Stijn
    Avatar
    Community Member
    46 Posts

    Re: .htaccess - rewrite Link to this post

    Can't post the site, but this is the content:

    ### SILVERSTRIPE START ###
    <Files *.ss>
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
    </Files>

    <IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_URI} !(\.gif$)|(\.jpg$)|(\.png$)|(\.css$)|(\.js$)

    RewriteCond %{REQUEST_URI} ^(.*)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
    RewriteRule ^products.asp$ /home/nl [R=301,QSA,L]

    </IfModule>

    ### SILVERSTRIPE END ###

  • banal
    Avatar
    Community Member
    901 Posts

    Re: .htaccess - rewrite Link to this post

    In my first reply, I wrote to put the rewrite rule before the SilverStripe rewrite-rules. So here's how it should look like for your site:

    ### SILVERSTRIPE START ###
    <Files *.ss>
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
    </Files>

    <IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteRule ^products.asp$ /home/nl [R=301,QSA,L]

    RewriteCond %{REQUEST_URI} !(\.gif$)|(\.jpg$)|(\.png$)|(\.css$)|(\.js$)

    RewriteCond %{REQUEST_URI} ^(.*)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
    </IfModule>
    ### SILVERSTRIPE END ###

  • Stijn
    Avatar
    Community Member
    46 Posts

    Re: .htaccess - rewrite Link to this post

    Thx! Now its works! I must mis read it :$

    2756 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.