Welcome to Welcome to DNF.com™ - Domain Sales, Domain Forum, Domain Appraisals, Domain Registrars

If you are new to domains and looking to buy, sell and learn about domains then you have come to the right place. DNForum is the largest domain name community on the internet and continues to grow every day. There are over 105,000 domainers on DNForum doing everything from buying domains, selling domains, learning about domains and discussing domains. Take a minute and Register.

Register Today on DNForum IT'S FREE!

Results 1 to 4 of 4
  1. #1
    Exclusive Lifetime Member

    Join Date
    Oct 2010
    Location
    ScrapingWeb.com
    Posts
    104
    Country

    China
    DNF$
    919
    Bank
    0
    Total DNF$
    919
    Donate  

    How to pass slash / in an URL?

    On this page there are many abbreviation / acronym entries: http://abbreviations.wordcrow.com/acronyms/D/

    They are generated in PHP:

    PHP Code:
    <a href="/define/<?php echo rawurlencode($abbreviation['title'])?>/">
        <strong><?php echo $abbreviation['title']?></strong>
    </a>
    I used rawurlencode because many acronyms contain bizarre characters such as #, & and even /.

    And the URL requests such as:

    http://abbreviations.wordcrow.com/define/DA%26E/

    Would first be fed to rawurldecode():

    PHP Code:
    $acronym rawurldecode('DA%26E'); // $acronym would be 'DA&E'. 
    And then used in database queries.

    While DA&E is all right, DA/C is not. Try this URL http://abbreviations.wordcrow.com/define/DA%2FC/ and you would end up with http://abbreviations.wordcrow.com/define/DA/C/ which is an error page.

    I can extend more code to recognize /define/DA/C/ but it's just weird and non-sensible. I tried both Chrome and Firefox and they all automatically convert DA%2FC to DA/C. But with DA%26E, they don't.

    What am I doing wrong? Ain't that / already encoded into '%2F'?? Really weird. Any help would be appreciated!
    Buy content databases as starting point of your niche information sites and web applications.
    Find help in developing them into fully functioning PHP website scripts with user / member systems and advanced administrator features.

  2. #2
    DNF Member

    Join Date
    Oct 2003
    Posts
    665
    DNF$
    3,986
    Bank
    0
    Total DNF$
    3,986
    Donate  
    Are you sure this is not due to your mod_rewrite which I assume you're using to create the URL? You usually have to 'escape' characters like that with a preceding \

    Also it may be a server setup issue - see http://httpd.apache.org/docs/2.2/mod...encodedslashes
    Last edited by RobM; 05-18-2011 at 06:05 AM.

  3. #3
    Exclusive Lifetime Member

    Join Date
    Oct 2010
    Location
    ScrapingWeb.com
    Posts
    104
    Country

    China
    DNF$
    919
    Bank
    0
    Total DNF$
    919
    Donate  
    Thanks, RobM. Here's the .htaccess in the /define/ directory:

    Code:
    <IfModule mod_rewrite.c>
    
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [L]
    
    </IfModule>
    And in /define/index.php:

    Code:
    $req = explode('/', $_SERVER['REQUEST_URI']);
    
    $acronym = rawurldecode($req[2]);
    
    ... // Database queries with $acronym
    I tried to add "AllowEncodedSlashes On" in the .htaccess but it didn't work. Any idea?
    Buy content databases as starting point of your niche information sites and web applications.
    Find help in developing them into fully functioning PHP website scripts with user / member systems and advanced administrator features.

  4. #4
    DNF Member

    Join Date
    Oct 2003
    Posts
    665
    DNF$
    3,986
    Bank
    0
    Total DNF$
    3,986
    Donate  
    I believe 'AllowEncodedSlashes On' has to actually be implemented at server level in the apache config file. So if this is not your server you'll have to ask the owning company to do it (they might refuse as some people believe it's not secure).

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
  •  

Domain name forum recommended by Domaining.com