Can't change folder name of project in Yii - php

I have a created a project named "ProjectName".
I want to change the project name to "NewProject"
I can't change the folder name of the project.
If i change the folder name, URL Manager functions not working.
But i can run proper by disable URLManager functions in /confing/main.php and put index.php? in the url
I have a proper .htaccess file.
No hard codes in my project.
Is any problem in server or code?

I found out the problem.
I add the following lines in apache httpd.conf file.
<Directory /var/www/path/to/NewProject>
AllowOverride All
Options Includes FollowSymLinks
</Directory>
These lines helps to look the .htaccess file. Otherwise ur server skips .htaccess file.
Thank u.

Related

How to load themes file properly using php

Talking about my project I am working, its just a simple website in localhost.I am Xampp server rand inside htdocs my website is in file creative which contains index.php file and another sub directory themes which further contains themes folder which contain all the necessary html php and css files that builds my websites.
When a user enters I want to redirect him from the index.php in localhost/creative to the index.php in localhost/creative/themes/theme-folder. I tried to use require_once('creative/themes/theme-folder/index.php'); but in most of cases it fails. is there any other way to do so.
You can modify the .httpd file.
Then you add:
#The path of your repositories:
DocumentRoot "C:/xampp/htdocs/creative"
#then you make an alias:
Alias /creative "C:/xampp/htdocs/creative/themes/theme-folder"
<Directory "C:/xampp/htdocs/creative/themes/theme-folder">
#Modify this data according to your needs
Options Indexes FollowSymLinks
AllowOverride all
Order Allow,Deny
Allow from all
</Directory>

Laravel : Redirections in a subfolder

I'm working on a local version of a website developed with Laravel. I have a URL like : http://localhost/s/SEO/userinstall which returns a 404 error. In the app/Http/routes.php , I tried the following but I'm still getting the same error :
Route::get('userinstall', 'InstallController#userinstall');
Route::post('userinstall', 'InstallController#saveUser');
Then I tried
Route::get('s/SEO/userinstall', 'InstallController#userinstall');
Route::post('s/SEO/userinstall', 'InstallController#saveUser');
I checked the AllowOverride directive in the Apache configuration file and it seems to be fine :
<Directory />
AllowOverride All
</Directory>
I'm using the defaut Laravel .htacess file. Any idea how I can fix this?
Thanks
By looking into your URL, http://localhost/s/SEO/userinstall
I am assuming s->SEO are directories under an apache root directory and because that you have to use "s/SEO/userinstall" in Route::get('s/SEO/userinstall', 'InstallController#userinstall');
You should Add the Apache Configuration of your website path "../s/SEO" assign a specific domain name. Such as http://sandbox.local such that you could access the site from http://sandbox.local/userinstall
That way, you could access the route by using
Route::get('userinstall', 'InstallController#userinstall');
Try to google it, to get an idea about, how you could setup your project to access through local domain.
Here is the URL which might help you. http://headsigned.com/article/setting-up-local-development-domain-with-apache-vhosts

XAMPP DirectiveIndex issue (php development)

I'm having an issue with using XAMPP and the ability to use an includes folder in php etc. I'm learning how to use a single point access for my php files, by that I mean, you put only an index.php in the main folder to be accessed and it is it use classes that are located in the Includes folder outside the public_php folder.
Here is the current config inside the httpd.conf (located in the apache2 folder)
Here is the current config :
Alias /bitnami/ "/Applications/XAMPP/xamppfiles/apache2/htdocs/"
Alias /bitnami "/Applications/XAMPP/xamppfiles/apache2/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.html index.php
</Directory>
Here is a screenshot of my file structure, is someone able to help me on how to use the DirectoryIndex setting so that my program is able to just use the require_once 'bla/bla.php';
Thanks for any contribution given.
require_once (and it's other variations) include files locally.
You don't have to use your alias to access them, just write the full local path:
if you file is located at /Applications/XAMPP/bla/bla.php:
require_once('/Applications/XAMPP/bla/bla.php');

Loading Correct Index File

I'm trying to figure out how to tell Netbeans to load the index file that is inside of my public_html folder when the project is ran and I'm not sure how to.
Sources : http://screencast.com/t/kWMCRKOWoo
Run Configuration : http://screencast.com/t/SqZTN7Pu
EDIT :
Can anybody expand on the answer below? Any additional ideas with seeing my two screenshots.
Rightclick on the project in the project explorer.
Click Properties.
Select Run Configurations under categories section.
Update the Project url & Index file fields.
Done ! :)
Update Project folder & Source folder too under sources category if those are incorrect.
You can via localhost only run files inside
http://localhost/WrestlingManager/index.php
and that is mapped to
C:\xampp\htdocs\WrestlingManager\index.php
and that's what you have set in your run configuration.
It's easy if you can run in a browser (for example).
http://localhost/WrestlingManager/public_html/index.php
If you want to run files from another location . You must that folder have in your server conf file
Alias /public_html = "C:/Netbeans/Projects/PhpApp1/public_html"
from my Apache httpd.conf
Alias /samples "D:/mysamples/xysamples"
<Directory "D:/mysamples/xysamples">
Options Indexes FollowSymLinks MultiViews ExecCGI
Order allow,deny
Allow from all
</Directory>
Now I can : http:/localhost/samples
I can not see the real path of the public_html folder inside of your Netbeans project .
In Run configuration you can set
Project URL : http://localhost/WrestlingManager/public_html/
Index File : index.php

How can I add one line into all php files' beginning?

So, ok. I have many php files and one index.php file. All files can't work without index.php file, because I include them in index.php. For example. if somebody click Contact us the URL will become smth like index.php?id=contact and I use $_GET['id'] to include contacts.php file. But, if somebody find the file's path, for example /system/files/contacts.php I don't want that that file would be executed. So, I figured out that I can add before including any files in index.php line like this $check_hacker = 1 and use if in every files beginning like this if($check_hacker <> 1) die();. So, how can I do it without opening all files and adding this line to each of them? Is it possible? Because I actually have many .php files. And maybe there is other way to do disable watching separate file? Any ideas? Thank you.
You could put your index.php alone in your web directory. And put all the files it includes in another non web directory.
Let's say you website http://www.example.com/index.php is in fact /path/to/your/home/www/index.php, you can put contact.php in /path/to/your/home/includes/contact.php. No .htaccess, rewrite, auto appending. Just a good file structure and a server configured like needed.
Edit to detail my comment about using xamp :
In your httpd.conf file, add something like this :
<Directory "/path/to/your/site/root">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
<VirtualHost *:80>
DocumentRoot /path/to/your/site/root
ServerName www.example.org
</VirtualHost>
Then in your windows hosts file (in C:\Windows\System32\drivers\etc), add this line :
127.0.0.1 www.example.com
I would highly recommend to use the .htaccess file to rejects all requests for files diffrent to index.php but I am not quite sure how to do that propperly.
This might work (can't test it now) but it will also block requests to css, js and so on:
order deny,allow
<FilesMatch "\.php">
deny from all
</FilesMatch>
<FilesMatch "(index.php)">
allow from all
</FilesMatch>
If someone knows the right solution, please edit my answer.
You might check this question: Deny direct access to all .php files except index.php
So you might have a FilesMatch only for php files in addition to the index.php rule.
EDIT: The new version of the code seems to work.
In response to Kau-Boy:
Place all your php files (except index.php) in a new directory and put the .htaccess file with the following contents:
deny from all
Make sure you don't put any images/css/jscript resources in this directory, because they will be blocked as well.
I'd use mod_rewrite in this case (if you are using Apache). It's much cleaner solution than writing gazillions of useless ifs in PHP.
This way, if someone wanted to "hack it" and tried /system/files/contacts.php, it'd redirect them to index.php?id=contact or whatever other site.
In your php.ini or in you htaccess set the following variable:
auto_prepend_file="[path to some .php file]"
This will include a header file of your choice that will be included before all php scripts on the system.
The php.ini directive auto_append_file, will create a footer that is included at the end of all PHP files on the system.
Check out the technique at http://www.electrictoolbox.com/php-automatically-append-prepend/
RewriteCond %{REQUEST_URI} system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
Will redirect any attempt to system folder back to root!

Categories