I'm trying to install a Kohana web page in a server that has another applications and I'm getting the error 'No direct access allowed'.
When I try to go to index page I see the directory. I think that it has something to do with .htaccess file or SYSPATH, but i can't figure it out.
Someone can help me?
Thank you very much
Difficult to guess what the cause of your problem might be, but do you have a line that begins RewriteBase in your .htaccess?
If not try adding one before the RewriteRule .* index.php/$0 [PT] line, in the format:
RewriteBase /directory-name-here/
So if the directory your kohana application's in is named kohana, you want a line like:
RewriteBase /kohana/
SYSPATH is defined in index.php of Kohana framework.
so make sure your .htaccess is poining to correct index file.
Related
until now I have always used htaccess to rewrite URLS in order to have non-SEF url to SEF urls.
Today I am facing a new challenge that honestly, beeing non confident in regular expression, I really don't know how to achieve.
I have a situation where a forum on a website of mine has been update in the following form:
previous link: www.domain.com/forum3/topic/name-of-topic/post/7548
new link: forum.domain.com/Topic-name-of-topic/
How do I intercept /post/37764 string and tell htaccess to not consider it?
And how to instruct the server to build that kind of url instead of the provious. I am very confused about it.
Any suggestion? Thank you very much. Is there any resource that I can read to help me better understand the case?
Thanks again.
EDIT
Florian answer is correct. I just added few mods to fit it better.
RewriteEngine On
#RewriteBase /
RewriteRule ^forum3/topic/([^/]+)/post/[0-9]+$ http://forum.domanin.com/Topic-$1/ [L,R=301]
RewriteRule ^forum3/topic/([^/]+)-[0-9]+$ http://forum.domanin.com/Topic-$1/ [L,R=301]
You can try this code :
RewriteEngine On
RewriteBase /
RewriteRule ^forum3/topic/([^/]+)/post/[0-9]+$ /Topic-$1/ [L,R=301]
/([^/]+)/ means that we want to catch a string containing one or more characters except / preceded and followed by a /.
This link might help you to test your .htaccess files :
Test your apache htaccess files online
Currently I have a site, https://mysite.com/ a working Drupal7 site. I want to have something like this, https://mysite.com/dev in order for me to test the things first on this location before finally uploading it to the main site. What I did was copy the entire folder where all the files located and pasted it inside /dev. I made a duplicate of the DB being used by the main site and edited the file settings.php under sites/default/, edited the base url from https://www.mysite.com/ to https://www.mysite.com/dev. But when I tried navigating the pages using the links(menu, admin) it gives me Page not found response. In addition, I did uncomment this line RewriteBase / on my .htaccess file. I can also log in, but after logging in the links point to the main site like this, https://mysite.com/link1, https://mysite.com/link2 and so on. What did I miss? Can someone please help? Thanks!
I think I finally got it working. I did mention I edited a single line on my .htaccess file which is the RewriteBase / and I did, I promise. I changed it to RewriteBase /dev but when I tested the site, the links still go to the main site as I have mentioned above. What I did was research more on editing .htaccess and somewhere down the road I got here. I lack a few lines of codes which will solve my dilemma, somewhere between RewriteCond and RewriteBase lines. I need to add these lines, RewriteCond %{REQUEST_URI} ^/dev
RewriteRule ^ dev/index.php [L]. After adding these two lines, I tested the site again and it worked like magic. That's it. Thank you guys.
I have a file that is located at:
http://www.mydomain.com/alcamino/includes/display_objects/custom/camino-tools/RemotingService.cfc
I would like to be able to access RemotingService.cfc like this:
http://www.mydomain.com/remoting/RemotingService.cfc
I have tried several different Rewrite rules but none are working correctly.
Can anyone point me in the right direction?
Thanks
Try adding this in the htaccess file in your document good
RewriteEngine On
RewriteRule ^/?remoting/RemotingService.cfc$ /alcamino/includes/display_objects/custom/camino-tools/RemotingService.cfc [L]
I am use Codeigniter to creat my site. it is a huge site with a lot of contents.
i use the default welcome controller for all pages.
the path is like this now
http://mydomain.com/index.php/welcome
and my folder structure is like this
/root
/codeigniter Application folder
/controller
/view
/static/
/images/
/css/
/pdf/
.htaccess
because i am doing the content first, so all the images are set to absolute patch (http://mydomain.com/static/images/foldername/pc.jpg)
now when i use the rewrite to remove "inde.php" and "welcome"
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|system|pdf|sitemap\.xml|profile.htm|^([A-z,0-9,_,-]+).asp|(.*)\.pdf|phpadmin)
RewriteRule ^(.*)$ /index.php/welcome/$1 [L]
all css and image file are not accessible anymore. I have nearly a thousand pages with images. I don't have the time to change the page one by one. the deadline is coming, please help.
thanks
Have you tried adding the css-folder to your excluded rewriteconditions?
RewriteCond $1 !^(index\.php|images|robots\.txt|system|pdf|sitemap\.xml|profile.htm|^([A-z,0-9,_,-]+).asp|(.*)\.pdf|phpadmin)
Does not seem to exclude the folder css from rewriting (see images is excluded).
Try something like
RewriteCond $1 !^(index\.php|images|css|robots\.txt|system|pdf|sitemap\.xml|profile.htm|^([A-z,0-9,_,-]+).asp|(.*)\.pdf|phpadmin)
Good luck
I think the problem lies with your .htaccess file. We have a similar setup, and that url living outside of the application directory is available just as you have it with a direct url relative to its path. Check out the wiki at http://codeigniter.com/wiki/mod_rewrite for the correct way to set up your .htaccess file.
Edit to clarify: The url http://mydomain.com/static/images/foldername/pc.jpg should work. something about your .htaccess file is wrong.
RewriteCond $1 !^(static|index.php|images|robots.txt|system|pdf|sitemap.xml|profile.htm|^([A-z,0-9,_,-]+).asp|(.*).pdf|phpadmin)
I want to change my url with only the parameter. As I am passing only one parameter, so I want the sub url should be changed with my parameter name. I want change the url as the following type-
From:
http://www.xyz.com/cat.php?slag=season
to
http://www.xyz.com/season
Can anyone help me to do it. I don't know how to do it. Thanks
Options +FollowSymLinks
RewriteEngine On
RewriteBase /path/to/your/directory
RewriteRule ^(.*)cat/(.*)$ cat\.php?slag=$2&%{QUERY_STRING} [L]
put the above in your .htaccess file.. and that would do the magic..
Note :
RewriteBase /path/to/your/directory
(use this line only if your application is in any of subfolder the folder)
I suggest you obtain a copy of the .htaccess that WordPress uses. It's a quite powerful starting point that allows you to handle routing internally from within your Application - which you might feel more comfortable with, as it seems to me.