Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Nov 2009
    Posts
    62
    Thanks
    9
    Thanked 0 Times in 0 Posts

    SEO friendly url form submit

    Hi!
    I have a problem.I made a website with seo friendly urls,just for practice.The problem is,when i try to submit the contact form that doesn't work.I tried to google the solution but none of the suggestions worked.And i'd like to undersstand the problem as well,because at the moment i don't have any idea what is the problem.Any help welcomed.
    The structure of the relevant files is:
    In the root:index.php (I know a white list would be necessary)
    PHP Code:
           <?php
              
    if(isset($_GET['q'])){ ?>
                <?php  $page 'includes/'.$_GET['q'].".php";

              }else{
                  
    $page "includes/home.php";

              }
              include(
    $page);
              
    ?>
    includes dir: all the other php files

    htaccess:
    Code:
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Change
    RewriteRule ^(.*)$ index.php?q=$1

    to
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

    See RewriteRule Flags - Apache HTTP Server
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Nov 2009
    Posts
    62
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Thanks,i tried it,but nothing has changed.
    The form handled by contact.php:
    PHP Code:
    <form action="contact" method="post" id="contactform_main"
    If i click submit the page just loads,loads....

    If i modify it to:

    PHP Code:
    <form action="includes/contact.php" method="post" id="contactform_main"
    the whole contact.php is included again in the form.

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Perhaps you just need <form action="/contact" method="post" id="contactform_main">
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    New Coder
    Join Date
    Nov 2009
    Posts
    62
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Still no luck.

    <p>The requested URL /contact was not found on this server.</p>
    Same with the /includes/contact .

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    What's the url of your contact page before submit? Please post a link to your page, if you have hosted it.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #7
    Regular Coder
    Join Date
    Sep 2011
    Posts
    428
    Thanks
    18
    Thanked 26 Times in 26 Posts
    It should just be 'contact'.

    With that rule of htaccess rewrite, anything after the domain (after the forward slash) will be set to the $_GET variable, which in this case is $_GET['q'];

    Basically, with your rules, visiting http://example.com/contact will cause the page to forward the request to index.php in the following format: http://example.com/index.php?q=contact.
    With the conditions you set, if you have a directory/file named contact or anything else you want to use in that directory, the request will fail and act as if it were going to it normally, i.e. http://example.com/contact/index.php. I'm not sure about the -l one, I can only seem to find listing as what it means (I've never used it), however whatever it's for it has the same role as files and directories (if it's there it won't rewrite).

    Remember this if you use words such as 'settings', 'img', 'images', 'css', 'js', etc. as they are common folder names and won't be redirected (although you might not want all of them to pass to php.


  •  

    Posting Permissions

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