I would like to know if it's possible to point my domain to a directory which is two folders in from the root.
The point is, I inform the page that will be showed in the content area trought the URL variable, like this:
www.dominio.com.br/index.php?c=products/list (in this way, it works well)
I would like to access this path by using: www.dominio.com.br/products/list
This is my structure...
public_html
.htaccess
index.php
**products**
**list.php** <-- My desired folder.
customers
list.php <-- My desired folder.
new.php
I need a .htaccess code for read this URL with sub-directory folder in the variable. For now, I could make work when using the file in the same folder as index.php.
I hope this all makes sense.
Thanks.
If
www.dominio.com.br/index.php?c=products/list
Works well for you, you could use a rewrite rule to map a 'virtual' folder path to your existing page:
RewriteEngine On
RewriteRule ^products/list$ index.php?c=products/list
Related
I have a directory structure like
/logging.php
/customer1/
/customer2/
/customer3/
...
Now I need to log all access of the subdirs customer1, customer2, customer3 and so on.
Can I somehow (like a htaccess rule) lead all access trough a php file logging.php which saves the access into a mysql database and than forwards to the wanted directory?
I don't want to include the logging.php in every single file of the subdirs, as the subdirs are dynamically generated.
A simple .htaccess rule should suffice.
RewriteRule ^(customer\d+(/.*)?)$ /logging.php?path=$1 [L]
Within logging.php, just look at $_GET['path']
This is assuming that the directory and files in question are in the web root of your site (Usually something like public_html/ or wwwroot/)
I'm trying to achieve something with .Htaccess RewriteEngine.
I want to be able to controll subfolders via one single .Htaccess file, currently to get this working I have to have the same .Htaccess file in every folder & subfolder but it would be great to just have one in the ROOT folder to avoid copy-pasting.
Currenty my structure looks like this:
ROOT
Images
2012
January
February
...
2013
...
Other
Misc
Folders contain images that are accessed by index.php?i=IMG_NAME and by using the following
RewriteEngine on
RewriteRule ^([^/\.]+)$ index.php?i=$1 [L]
I can use for example: Images/2012/January/IMG_NAME and it works fine to load the image.
But as mentioned I have to have the above .Htaccess file in every folder & subfolder to get it working, otherwise I have to use Images/2012/January/?i=IMG_NAME are there any workarounds for this?
I know this only skirttails the issue but if you don't have the actual url point to a real folder then you can run everything from the .htaccess file from public_html.
So if you actually stored the images in /data/2012/January/*
Then had the url that is used by /Image/2012/January/IMG_NAME
I like to rewrite urls and redirect them to inside a symlink.
I googled almost the whole net but every comment what I found are writes about symlinks inside a web folder.
But in my case all the files are inside a symlinked folder also with the htaccess file.
But the redirect doesnt work. I think it happened because of the symlink.
So, my folder structure looks like:
www.domain.com
~symlink
dir1
dir2
.htaccess
index.php
Does somebody have a good idea to solve this redirection?
thx
I recently uploaded my codeigniter project onto my web server.
it's in a folder called project1 this is what my directory view looks like
[www.myurl.com]
|-> project1
|-> application
|-> css
|-> images
|-> js
I am having two problems.
The first is that I want it to load my welcome view when I go to (www.myurl.com) and not
(www.myurl.com/project1/main_controller/index.php/welcome). How do i get rid of all that garbage?
The second problem is when I use <?php echo base_url();?> it shows up fine in view source but when I click on it, it echo's the url [www.myurl.com/project1/www.myurl.com/project1/] why is it doing this?
It looks like you've installed CodeIgniter into a subdirectory. If you want your CI site to load from the root url, you should copy it one directory up so the Application & System folders are directly under the root url of your web directory. From there, the .htaccess rules that are posted by shail (and quoted below) should take care of removing the index.php in your paths.
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ ci/index.php/$1 [L]
Regarding the site_url() issue, make sure you have your $config['base_url'] variable set in application/config/config.php and that it contains the trailing slash.
$config['base_url'] = "http://www.myurl.com/";
To test this further, try passing a parameter to the site_url() function like this:
echo site_url(welcome);
Which should return: http://www.myurl.com/welcome if everything is set right.
Getting CI up and running is rather simple. Most of it requires you to edit a few configuration
files.
You need to setup CI to point to the right base URL of the app. To do this, open up system/application/config/config.php and
edit the base_url array item to point to your server and CI folder.
view plaincopy to clipboardprint?
$config['base_url'] = "http://localhost/ci/";
Currently, the CI setup will have a default controller called “welcome.php”; you can find this in the system/application/controllers folder. For this tutorial, delete it and open your system/application/config/routes.php file. Change the default array item to point to the “helloworld” controller.
view plaincopy to clipboardprint?
$route['default_controller'] = "Helloworld"
CI also has a view file that we do not need. Open up the system/application/view/ folder
and delete the welcome_message.php file.
You can change your default controller here.
In order to edit Url http://localhost/ci/index.php/helloworld/.There are a few things you can do to improve your CodeIgniter experience -
like removing that annoying index.php bit out of the URL. You can accomplish this task by creating a .htaccess file in the root folder, and adding the following code.
RewriteEngine on
RewriteCond $1 !^(index.php|images|robots.txt)
RewriteRule ^(.*)$ ci/index.php/$1 [L]
You’ll also need to open up the config.php file in system/application/config/ and edit the index_page array item to a blank string.
view plaincopy to clipboardprint?
$config['index_page'] = "";
Another nifty trick is to turn on CI’s ability to parse PHP alternative syntax if its
not enabled by the server. To do this, open up the same file as before, system/application/config/config.php, and set the rewrite_short_tags array item to TRUE.
view plaincopy to clipboardprint?
$config['rewrite_short_tags'] = TRUE;
I hope all goes well!
I have a php websites hosted on a server. I use CPanel to manage it. public_html has lets say following directory structure
public_html
- dir1
- dir2
- dir3
- ....other files.....
- website2home
Now I am trying to make website2home as the base directory of my website, but files inside website2home use some files from public_html folder and some files from within itself.
THE PROBLEM
When I assign a domain name to website2home, It does not reads the files from public_html folder (in fact, public_html folder is not visible) and shows some php warnings and some 404 not found errors. But lets say the domain name for original website is www.aaa.com, then if I access website2home by using www.aaa.com/website2home all works fine.
So My Question...
Is there any way to set the base directory, so that my website2home fetches all files and correct files without replacing hundreds of filepaths in php code?
Please answer considering that I don't want to modify source files of website.
I believe you are looking for some kind of .htaccess configuration. For instance, you may set your website2home folder as base folder for your www.aaa.com domain and then redirect some file access to other folders using .htaccess, something like this..
RewriteEngine on
RewriteRule captcha.jpg ../captcha.jpg
RewriteRule \.pdf$ ../pdf_files/$1
Have a look to mod_rewrite documentation
Edit: If, for some reason, the ../ redirection doesn't work, you always can redirect all your files to a pseudo-index PHP page. For instance:
RewriteEngine on
RewriteRule captcha.jpg my_index.php?access=../captcha.jpg
RewriteRule \.pdf$ my_index.php?access=../pdf_files/$1
And then, in your index PHP page you can simply load your PHP files in other folder:
require "../pdf_files/$requested";