I have massage "Disallowed Key Characters" whit url like this:
/project/category/Португалски
if url containd only latin chars problem is gone.
Problem come after removing index.php.
For removing i use in
config.php :
$config['index_page'] = "";
and
.htacces
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L]
After this url's work fine exept this url's whit cyrillic chars.
I read many questions for this before me and try differend solutions like:
in core/input/ _clean_input_keys function i change
if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
to
if ( !preg_match("/^[a-z0-9а-яА-Я~%:_\/-]+$/i", $str))
i tried other variant of this expresion but result is the same.
in config.php i change:
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_-';
to
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-а-яА-Я';
after this i tried
$config['permitted_uri_chars'] = 'a-zA-Z\p{Cyrillic}0-9~%.:_\-';
result sill is same. Massage "Disallowed Key Characters".
When i remove .htaccess rile and put again index.php in config all work whit cyrillic without problem.
SOLVED -
I just change text in.htaccess file to:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Now evriting is work fine :)
Related
I try to rewrite urls like:
http://www.example.com/contoller/method/var1/var2/var3
to
http://www.example.com/index.php?q=contoller/method/var1/var2/var3
My rewrite rules are as below:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
It works well except with doubles slashes. Indeed, there are replaced by singles slashes.
I would like to be able to use it when a var is empty. For example, if the var2 is empty the URL contains a double slashes on the var2 location
Just use
RewriteRule ^ index.php [L]
The URL you're corrupting in the query string is already available within index.php as $_SERVER['REQUEST_URI'].
I am using Codeigniter for one of my apps and have a following htaccess file
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|downloads|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]
Now i have a url which is like mydomain.com/group/username
For SEO reasons i am suppose to convert this url into mydomian.com/group/username into mydomian.com/username using 301 redirect
Also urls like mydomain.com/group/username/page1 should redirect to mydomian.com/username/page
The closest i have tried after googling is by pasting this below line at the end of the file
RewriteRule ^(.*?)/?group(.*)$ /$1 [L]
But it isnt working.. any idea where i have gone wrong ?
The answers on other questions doesnt seem to be working for me/ Am pretty bad with .htaccess
P.S - i tried this
RewriteRule ^group/username(.*)$ username/$1 [QSA,R=301,L]
It works fine but it gives consecutive slashes like mydomain.com/username//pagename
I have figured it out
RewriteRule ^group/username(.*)$ username$1 [QSA,R=301,L]
This is will simply remove the 'group' from your URL and will do 301 redirect
If
RewriteRule ^group/username(.*)$ username/$1 [QSA,R=301,L]
gives two slashes, change it to:
RewriteRule ^group/username/(.*)$ username/$1 [QSA,R=301,L]
The (.*)$ matches anything after username (including the slash) until the end.
I have a liitle mod_rewrite problem.
I have index.php (in root directory) which contains simple href link:
Novice
When I click on Novice, redirects me on novice.php file (which is mod_rewrited, that doesn't look like novice.php?query=this-is-something in URL, but looks like novice/this-is-something (this-is-something is my query)) The problem is, when I'm trying to GET "this-is-something" query in novice.php file.
I'm getting this query in novice.php file like that:
if (isset($_GET['query'])){
$query=$_GET['query'];
echo $query;
}else{
echo 'Null parameters.';
}
But it outputs just 0
But when I'm passing numbers in href link, like that:
Novice
The output in novice.php file is correct: 2131
I have code in my .htaccess like that:
RewriteRule ^novice/([^/\.]+)/?$ novice.php?query=$1 [L]
So what am I doing wrong in mod_rewrite, that i can get numbers through $_GET method, but I can not get string or charachters through $_GET?
I found solution by myself.
I've just changed "query" word at the end of RewriteRule ^novice/([^/.]+)/?$ novice.php?query=$1 [L]
to
"blabla" word -> RewriteRule ^novice/([^/.]+)/?$ novice.php?blabla=$1 [L]
And then works everything... Very strange...
if (isset($_GET['blabla'])){
$blabla=$_GET['blabla'];
echo $blabla;
}else{
echo 'Null parameters.';
}
It echo's now the parameter this-is-something.. But still don't know what was the problem.. I've just changed the name of variable "query" which was containing parameter "this-is-something"..
Btw if someone is interested: my .htaccess looks like this:
Options +FollowSymLinks
RewriteEngine On
# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://localhost/local_ageo.si/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://localhost/local_ageo.si/$1 [R=301,L]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
RewriteRule ^novice/([^/\.]+)/?$ novice.php?blabla=$1 [L]
CodeIgniter beginner here. The base URL of my website is 'http://localhost/routing/'.
// config.php
$config['base_url'] = 'http://localhost/routing/';
I'm simply trying to route the url 'http://localhost/routing/admin' to the admin controller using the following rules but it doesn't work. Instead I have to use 'http://localhost/routing/index.php/admin'.
$route['default_controller'] = 'seasons';
$route['admin'] = 'admin';
$route['404_override'] = '';
Question: is there a way to remove 'index.php' from the url?
Make changes in .htaccess file and config.php
application/config.php
$config['index_page'] = '';
.htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
is there a way to remove 'index.php' from the url?
Yes, as well as being a very popular question on SO, it is covered in the CodeIgniter documentation (which is very good and I highly recommend reading).
In your .htaccess write this. Also look for additional information : Codeigniter Guide
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt) # exceptions
RewriteRule ^(.*)$ /index.php/$1 [L]
In my config file, I have:
$config['url_suffix'] = "/";
Here is my .htaccess:
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^.+[^/]$
RewriteRule ^(.+)$ $1/
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
When I load a page, I don’t get the trailing slash. I am using URI routing, but even when I go to the actual path of the controller/view, I still don’t get the trailing slash.
What am I doing wrong? I tried removing the slash after the .php in the last line of the .htaccess, but that didn’t do it.
Even if I add “.html” as my URL suffix, it doesn’t get added. And that’s not in my .htaccess.
If I try to make $route['news-and-events'] = "news"; this instead: $route['news-and-events/'] = "news"; I get a 404 error
EDIT: With the above .htaccess I get an error that I am using disallowed characters, even when I add "/" to my allowed characters string in the config file.
Found a one that worked for me, Imported my Blogger posts to my Wordpress, and then my back links didn't work, so I just replaced my .htaccess with this example, check it out!
http://www.high-on-it.co.za/2011/02/removing-trailing-html-from-url/
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} \.html$
RewriteRule ^(.*)\.html$ $1 [R=301,L]
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]