Jump to content

htaccess with exeption and more


Tanja

Recommended Posts

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 by Tanja
Link to comment
Share on other sites

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 by requinix
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.