Tanja Posted February 13, 2016 Share Posted February 13, 2016 (edited) I´m trying to get nice urls....Everthing works fine, but I can´t get my upload-script going to work... I tried many options, but called (or included/required) elements are throwing errors.Without rewrite script works fine.Actually my htaccess: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^ indextest.php [QSA,L] How can I except the folder album?And: at the moment language is calling by GET - h t t p ://w w w.xxx.com/album/picture.php?lang=en is it possible to return h t t p ://w w w.xxx.com/en/album/picture ??at last: rewrite rule to route all callings without www to www....Thanks for help! Edited February 13, 2016 by Tanja Quote Link to comment https://forums.phpfreaks.com/topic/300803-htaccess-with-exeption-and-more/ Share on other sites More sharing options...
requinix Posted February 14, 2016 Share Posted February 14, 2016 (edited) Forms can't natively do that. 1. Put a redirect in picture.php so people accidentally going to that URL get redirected to the correct one automatically. (Which only works for GET requests.) 2. Put some Javascript in your form that will alter the form information as it gets submitted. As in you can set the target to /album/picture.php normally in the HTML, then use Javascript to change the action to /lang/album/picture (getting the lang from the form data) when it's submitted. My take on the second half: <form action="/album/picture.php" method="get" data-rewrite-action="/:lang/album/picture"> $(function() { $(document).on("submit", "form[data-rewrite-action]", function() { var elements = this.elements; this.action = $(this).data("rewrite-action").replace(/:([a-z-]+)/i, function($0, $1) { return encodeURIComponent(elements[$1] ? $(elements[$1]).val() : $1); }); }); }); POC For the www thing, RewriteCond %{HTTP_HOST} !=example.com RewriteRule ^ http://www.example.com%{REQUEST_URI} [L,R=301](replacing example.com with your domain) Edited February 14, 2016 by requinix Quote Link to comment https://forums.phpfreaks.com/topic/300803-htaccess-with-exeption-and-more/#findComment-1531088 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.